Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / db / __init__.py @ 1cfd5d4d

History | View | Annotate | Download (1.9 kB)

1 ba2a5b2c Giorgos Verigakis
# Copyright 2011 GRNET S.A. All rights reserved.
2 ba2a5b2c Giorgos Verigakis
#
3 ba2a5b2c Giorgos Verigakis
# Redistribution and use in source and binary forms, with or
4 ba2a5b2c Giorgos Verigakis
# without modification, are permitted provided that the following
5 ba2a5b2c Giorgos Verigakis
# conditions are met:
6 ba2a5b2c Giorgos Verigakis
#
7 ba2a5b2c Giorgos Verigakis
#   1. Redistributions of source code must retain the above
8 ba2a5b2c Giorgos Verigakis
#      copyright notice, this list of conditions and the following
9 ba2a5b2c Giorgos Verigakis
#      disclaimer.
10 ba2a5b2c Giorgos Verigakis
#
11 ba2a5b2c Giorgos Verigakis
#   2. Redistributions in binary form must reproduce the above
12 ba2a5b2c Giorgos Verigakis
#      copyright notice, this list of conditions and the following
13 ba2a5b2c Giorgos Verigakis
#      disclaimer in the documentation and/or other materials
14 ba2a5b2c Giorgos Verigakis
#      provided with the distribution.
15 ba2a5b2c Giorgos Verigakis
#
16 ba2a5b2c Giorgos Verigakis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 ba2a5b2c Giorgos Verigakis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 ba2a5b2c Giorgos Verigakis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 ba2a5b2c Giorgos Verigakis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 ba2a5b2c Giorgos Verigakis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 ba2a5b2c Giorgos Verigakis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 ba2a5b2c Giorgos Verigakis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 ba2a5b2c Giorgos Verigakis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 ba2a5b2c Giorgos Verigakis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 ba2a5b2c Giorgos Verigakis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 ba2a5b2c Giorgos Verigakis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 ba2a5b2c Giorgos Verigakis
# POSSIBILITY OF SUCH DAMAGE.
28 ba2a5b2c Giorgos Verigakis
#
29 ba2a5b2c Giorgos Verigakis
# The views and conclusions contained in the software and
30 ba2a5b2c Giorgos Verigakis
# documentation are those of the authors and should not be
31 ba2a5b2c Giorgos Verigakis
# interpreted as representing official policies, either expressed
32 ba2a5b2c Giorgos Verigakis
# or implied, of GRNET S.A.
33 ba2a5b2c Giorgos Verigakis
34 ba2a5b2c Giorgos Verigakis
from django.db.backends.signals import connection_created
35 ba2a5b2c Giorgos Verigakis
36 ba2a5b2c Giorgos Verigakis
37 ba2a5b2c Giorgos Verigakis
def activate_foreign_keys(sender, connection, **kwargs):
38 ba2a5b2c Giorgos Verigakis
    """Enable integrity constraint with sqlite."""
39 ba2a5b2c Giorgos Verigakis
    if connection.settings_dict['ENGINE'] == 'django.db.backends.sqlite3':
40 ba2a5b2c Giorgos Verigakis
        cursor = connection.cursor()
41 ba2a5b2c Giorgos Verigakis
        cursor.execute('PRAGMA foreign_keys = ON')
42 ba2a5b2c Giorgos Verigakis
43 ba2a5b2c Giorgos Verigakis
connection_created.connect(activate_foreign_keys)