Add local_settings.d/ dir for settings snippets
All files ending with '.py' in local_settings.d/ are evaluated after reading the settings from local_settings.py . That means changing the settings can be done without changing local_settings.py . Change-Id: I0b25ef2c4dada23f8cb66aa5e8af44b3a1cba3b9 Implements: blueprint local-settings-override-mechanism
This commit is contained in:
parent
21963a2ad2
commit
c9fdecc8e8
@ -292,6 +292,23 @@ Most of the following settings are defined in
|
|||||||
``openstack_dashboard/local/local_settings.py``, which should be copied from
|
``openstack_dashboard/local/local_settings.py``, which should be copied from
|
||||||
``openstack_dashboard/local/local_settings.py.example``.
|
``openstack_dashboard/local/local_settings.py.example``.
|
||||||
|
|
||||||
|
Since Mitaka, there is also a way to drop file snippets into
|
||||||
|
``openstack_dashboard/local/local_settings.d/``. These snippets must end with
|
||||||
|
``.py`` and must contain valid Python code. The snippets are loaded after
|
||||||
|
``local_settings.py`` is evaluated so you are able to override settings from
|
||||||
|
``local_settings.py`` without the need to change this file.
|
||||||
|
Snippets are evaluated in alphabetical order by file name.
|
||||||
|
It's good style to name the files in ``local_settings.d/`` like
|
||||||
|
``_ZZ_another_setting.py`` where ``ZZ`` is a number. The file must start with
|
||||||
|
an underscore (``_``) because Python can not load files starting with a number.
|
||||||
|
So given that you have 3 files, ``local_settings.py``,
|
||||||
|
``local_settings.d/_10_setting_one.py`` and ``local_settings.d/_20_settings_two.py``,
|
||||||
|
the settings from ``local_settings.py`` are evaluated first. Settings from
|
||||||
|
``local_settings.d/_10_settings_one.py`` override settings from ``local_settings.py``
|
||||||
|
and settings from ``local_settings.d/_20_settings_two.py`` override all other settings
|
||||||
|
because that's the file which is evaluated last.
|
||||||
|
|
||||||
|
|
||||||
``AUTHENTICATION_URLS``
|
``AUTHENTICATION_URLS``
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
# override the CUSTOM_THEME_PATH variable with this settings snippet
|
||||||
|
# CUSTOM_THEME_PATH="themes/material"
|
@ -267,6 +267,19 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
logging.warning("No local_settings file found.")
|
logging.warning("No local_settings file found.")
|
||||||
|
|
||||||
|
# allow to drop settings snippets into a local_settings_dir
|
||||||
|
LOCAL_SETTINGS_DIR_PATH = os.path.join(ROOT_PATH, "local", "local_settings.d")
|
||||||
|
if os.path.exists(LOCAL_SETTINGS_DIR_PATH):
|
||||||
|
for (dirpath, dirnames, filenames) in os.walk(LOCAL_SETTINGS_DIR_PATH):
|
||||||
|
for filename in sorted(filenames):
|
||||||
|
if filename.endswith(".py"):
|
||||||
|
try:
|
||||||
|
execfile(os.path.join(dirpath, filename))
|
||||||
|
except Exception as e:
|
||||||
|
logging.exception(
|
||||||
|
"Can not exec settings snippet %s" % (filename))
|
||||||
|
|
||||||
|
|
||||||
if not WEBROOT.endswith('/'):
|
if not WEBROOT.endswith('/'):
|
||||||
WEBROOT += '/'
|
WEBROOT += '/'
|
||||||
if LOGIN_URL is None:
|
if LOGIN_URL is None:
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Allow to override settings from local_settings.py with
|
||||||
|
file snippets dropped into local_settings.d/ directory.
|
Loading…
Reference in New Issue
Block a user