settings: changed to single file, with a execfile() tacked at the end (#6465)
This commit is contained in:
parent
ae50044b9a
commit
5923e47218
12
README
12
README
|
@ -41,15 +41,13 @@ The command line for starting is:
|
|||
|
||||
Passerelle is available on http://127.0.0.1:8000/
|
||||
|
||||
manage.py options
|
||||
-----------------
|
||||
|
||||
--config=/path/to/config.py
|
||||
Configuration file. See config_example.py for example.
|
||||
Settings
|
||||
--------
|
||||
|
||||
--multitenant
|
||||
Activate multi-tenant mode. The python-entrouvert package
|
||||
must be installed.
|
||||
Default settings are loaded from settings.py, they can be overloaded by a
|
||||
local_settings.py file set in the same directory, or by a file referenced
|
||||
in the PASSERELLE_SETTINGS_FILE environment variable.
|
||||
|
||||
|
||||
LICENSES
|
||||
|
|
28
manage.py
28
manage.py
|
@ -3,32 +3,8 @@ import os
|
|||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
multitenant = False
|
||||
config_file = False
|
||||
|
||||
argv = sys.argv[1:]
|
||||
for arg in list(argv):
|
||||
if arg.startswith('--'):
|
||||
if arg.startswith('--config='):
|
||||
config_file = arg.split('=')[1]
|
||||
argv.pop(0)
|
||||
elif arg == '--multitenant':
|
||||
multitenant = True
|
||||
argv.pop(0)
|
||||
else:
|
||||
print >>sys.stderr, 'ERR: Unsupported flag', arg
|
||||
sys.exit(1)
|
||||
else:
|
||||
break
|
||||
|
||||
if config_file:
|
||||
os.environ['DJANGO_CONFIG_FILE'] = config_file
|
||||
|
||||
if multitenant:
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passerelle.tenant_settings")
|
||||
else:
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passerelle.settings")
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "passerelle.settings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv[:1] + argv)
|
||||
execute_from_command_line(sys.argv)
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
# Django default settings for passerelle project.
|
||||
|
||||
from django.conf import global_settings
|
||||
import os
|
||||
import logging
|
||||
try:
|
||||
from logging.handlers import NullHandler
|
||||
except ImportError:
|
||||
# python < 2.7
|
||||
class NullHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
pass
|
||||
|
||||
logging.getLogger('passerelle').addHandler(NullHandler())
|
||||
|
||||
PACKAGE_PATH = os.path.dirname(__file__)
|
||||
|
||||
### Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'please-change-me-with-a-very-long-random-string'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': 'passerelle.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
### End of "Quick-start development settings"
|
||||
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale.
|
||||
USE_L10N = True
|
||||
|
||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
||||
USE_TZ = True
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://media.lawrence.com/static/"
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (os.path.join(PACKAGE_PATH, 'static'),)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + ('gadjo.finders.XStaticFinder',)
|
||||
|
||||
MIDDLEWARE_CLASSES = global_settings.MIDDLEWARE_CLASSES + (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'passerelle.base.middleware.SearchApiUser'
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'passerelle.urls'
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = 'passerelle.wsgi.application'
|
||||
|
||||
LOCALE_PATHS = (os.path.join(PACKAGE_PATH, 'locale'),)
|
||||
LANGUAGE_CODE = 'fr-fr'
|
||||
|
||||
TEMPLATE_DIRS = (os.path.join(PACKAGE_PATH, 'templates'),)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'django.core.context_processors.request',
|
||||
'passerelle.base.context_processors.template_vars',
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# system apps
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'south',
|
||||
# base apps
|
||||
'passerelle.base',
|
||||
'passerelle.datasources',
|
||||
'passerelle.repost',
|
||||
# connectors
|
||||
'clicrdv',
|
||||
'gdc',
|
||||
'choosit',
|
||||
'oxyd',
|
||||
'ovh',
|
||||
'mobyt',
|
||||
'pastell',
|
||||
'concerto',
|
||||
'bdp',
|
||||
# backoffice templates and static
|
||||
'gadjo',
|
||||
)
|
||||
|
||||
LOGIN_REDIRECT_URL = 'homepage'
|
||||
|
|
@ -1,14 +1,120 @@
|
|||
from django.conf.global_settings import *
|
||||
from passerelle.default_settings import *
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
# Django default settings for passerelle project.
|
||||
|
||||
from django.conf import global_settings
|
||||
import os
|
||||
import logging
|
||||
try:
|
||||
from logging.handlers import NullHandler
|
||||
except ImportError:
|
||||
# python < 2.7
|
||||
class NullHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
pass
|
||||
|
||||
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'])
|
||||
logging.getLogger('passerelle').addHandler(NullHandler())
|
||||
|
||||
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')
|
||||
PACKAGE_PATH = os.path.dirname(__file__)
|
||||
|
||||
### Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'please-change-me-with-a-very-long-random-string'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = True
|
||||
|
||||
# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': 'passerelle.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
### End of "Quick-start development settings"
|
||||
|
||||
|
||||
# If you set this to False, Django will not format dates, numbers and
|
||||
# calendars according to the current locale.
|
||||
USE_L10N = True
|
||||
|
||||
# If you set this to False, Django will not use timezone-aware datetimes.
|
||||
USE_TZ = True
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://media.lawrence.com/static/"
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (os.path.join(PACKAGE_PATH, 'static'),)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + ('gadjo.finders.XStaticFinder',)
|
||||
|
||||
MIDDLEWARE_CLASSES = global_settings.MIDDLEWARE_CLASSES + (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'passerelle.base.middleware.SearchApiUser'
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'passerelle.urls'
|
||||
|
||||
# Python dotted path to the WSGI application used by Django's runserver.
|
||||
WSGI_APPLICATION = 'passerelle.wsgi.application'
|
||||
|
||||
LOCALE_PATHS = (os.path.join(PACKAGE_PATH, 'locale'),)
|
||||
LANGUAGE_CODE = 'fr-fr'
|
||||
|
||||
TEMPLATE_DIRS = (os.path.join(PACKAGE_PATH, 'templates'),)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'django.core.context_processors.request',
|
||||
'passerelle.base.context_processors.template_vars',
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
# system apps
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.admin',
|
||||
'south',
|
||||
# base apps
|
||||
'passerelle.base',
|
||||
'passerelle.datasources',
|
||||
'passerelle.repost',
|
||||
# connectors
|
||||
'clicrdv',
|
||||
'gdc',
|
||||
'choosit',
|
||||
'oxyd',
|
||||
'ovh',
|
||||
'mobyt',
|
||||
'pastell',
|
||||
'concerto',
|
||||
'bdp',
|
||||
# backoffice templates and static
|
||||
'gadjo',
|
||||
)
|
||||
|
||||
LOGIN_REDIRECT_URL = 'homepage'
|
||||
|
||||
|
||||
local_settings_file = os.environ.get('PASSERELLE_SETTINGS_FILE',
|
||||
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
||||
if os.path.exists(local_settings_file):
|
||||
execfile(local_settings_file)
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
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'
|
Loading…
Reference in New Issue