settings: load local_settings.py from env (#6196)

This commit is contained in:
Frédéric Péters 2014-12-30 10:54:09 +01:00
parent 5d53ad725d
commit 31031985a2
1 changed files with 31 additions and 17 deletions

View File

@ -1,18 +1,34 @@
"""
Django settings for combo project.
# combo - content management system
# Copyright (C) 2014 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
Django settings file; it loads the default settings, and local settings
(from a local_settings.py file, or a configuration file set in the
COMBO_SETTINGS_FILE environment variable).
The local settings file should exist, at least to set a suitable SECRET_KEY,
and to disable DEBUG mode in production.
"""
import os
from django.conf.global_settings import *
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
@ -55,11 +71,10 @@ MIDDLEWARE_CLASSES = (
)
# Serve xstatic files, required for gadjo
from django.conf import global_settings
STATICFILES_FINDERS = global_settings.STATICFILES_FINDERS + \
STATICFILES_FINDERS = STATICFILES_FINDERS + \
('gadjo.finders.XStaticFinder',)
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + \
TEMPLATE_CONTEXT_PROCESSORS = TEMPLATE_CONTEXT_PROCESSORS + \
('sekizai.context_processors.sekizai',)
ROOT_URLCONF = 'combo.urls'
@ -109,8 +124,7 @@ COMBO_PUBLIC_TEMPLATES = {
}
}
}
try:
from local_settings import *
except ImportError:
pass
local_settings_file = os.environ.get('COMBO_SETTINGS_FILE',
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
if os.path.exists(local_settings_file):
execfile(local_settings_file)