67 lines
2.4 KiB
Python
67 lines
2.4 KiB
Python
from django.conf.global_settings import *
|
|
from passerelle.default_settings import *
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
import os
|
|
import logging
|
|
|
|
try:
|
|
import entrouvert
|
|
except ImportError:
|
|
raise ImproperlyConfigured('python-entrouvert MUST be installed for the multitenant mode to work')
|
|
|
|
SOUTH_TESTS_MIGRATE = False
|
|
TEMPLATE_LOADERS = ('entrouvert.djommon.multitenant.template_loader.FilesystemLoader',) + TEMPLATE_LOADERS
|
|
DEFAULT_FILE_STORAGE = 'entrouvert.djommon.multitenant.storage.TenantFileSystemStorage'
|
|
MIDDLEWARE_CLASSES = (
|
|
'entrouvert.djommon.multitenant.middleware.TenantMiddleware',
|
|
'entrouvert.djommon.multitenant.middleware.JSONSettingsMiddleware',
|
|
'entrouvert.djommon.multitenant.middleware.PythonSettingsMiddleware',
|
|
) + MIDDLEWARE_CLASSES
|
|
INSTALLED_APPS = INSTALLED_APPS + ('entrouvert.djommon.multitenant',)
|
|
TENANT_APPS = INSTALLED_APPS
|
|
|
|
TENANT_MODEL = 'multitenant.Tenant'
|
|
SOUTH_DATABASE_ADAPTERS = {
|
|
'default': 'south.db.postgresql_psycopg2',
|
|
}
|
|
SHARED_APPS = (
|
|
'django.contrib.staticfiles',
|
|
'django.contrib.auth',
|
|
'django.contrib.contenttypes',
|
|
'django.contrib.sessions',
|
|
'django.contrib.messages',
|
|
)
|
|
|
|
if 'DJANGO_CONFIG_FILE' in os.environ:
|
|
logging.getLogger('passerelle').debug('Loading setting file %r', os.environ['DJANGO_CONFIG_FILE'])
|
|
execfile(os.environ['DJANGO_CONFIG_FILE'])
|
|
|
|
if 'TENANT_BASE' not in globals():
|
|
logging.getLogger('passerelle').error('Unable to boot: You must define a TENANT_BASE in your settings')
|
|
raise ImproperlyConfigured('You must define a TENANT_BASE in your settings')
|
|
|
|
if 'DATABASES' not in globals():
|
|
logging.getLogger('passerelle').error('Unable to boot: You must define a DATABASES in your settings')
|
|
raise ImproperlyConfigured('You must define a DATABASES variable in your settings')
|
|
|
|
if DATABASES['default']['ENGINE'] != 'django.db.backends.postgresql_psycopg2':
|
|
raise ImproperlyConfigured('MULTITENANT only work with a postgresql database')
|
|
DATABASES['default']['ENGINE'] = 'tenant_schemas.postgresql_backend'
|
|
|
|
if DEBUG:
|
|
# Load debug toolbar when available
|
|
try:
|
|
import debug_toolbar
|
|
except:
|
|
pass
|
|
else:
|
|
logging.getLogger('passerelle').debug('loading debug_toolbar')
|
|
MIDDLEWARE_CLASSES += (
|
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
|
)
|
|
INSTALLED_APPS += (
|
|
'debug_toolbar',
|
|
)
|
|
|