settings: import /etc/portail-citoyen/config.json and /etc/portail-citoyen/config.json

This commit is contained in:
Benjamin Dauvergne 2014-07-01 13:52:55 +02:00
parent eebae2484e
commit e86d71ac0a
1 changed files with 15 additions and 0 deletions

View File

@ -57,6 +57,8 @@ MEDIA_URL = os.environ.get('MEDIA_URL', '/media/')
PASSERELLE_URL = os.environ.get('PASSERELLE_URL', '')
PASSERELLE_APIKEY = os.environ.get('PASSERELLE_APIKEY', '')
ETC_DIR = os.path.join('/etc', 'portail-citoyen')
STATICFILES_DIRS = ['/var/lib/%s/static' % PROJECT_NAME, os.path.join(PROJECT_PATH, 'static')]
if 'STATICFILES_DIRS' in os.environ:
STATICFILES_DIRS = os.environ['STATICFILES_DIRS'].split(':') + STATICFILES_DIRS
@ -314,6 +316,19 @@ for key in os.environ:
pass
globals()[setting_key] = value
JSON_CONFIG = os.path.join(ETC_DIR, 'config.json')
if os.path.exists(JSON_CONFIG):
import json
globals().update(json.load(JSON_CONFIG))
PY_CONFIG = os.path.join(ETC_DIR, 'config.py')
if os.path.exists(PY_CONFIG):
execfile(PY_CONFIG, globals())
# try to import local_settings.py (useless, in theory)
try:
from local_settings import *