Add support for updating configuration options from environment variables.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@ XX (2017-XX-XX)
|
||||
- Fix repeated permission list API URL. GitLab issue #389.
|
||||
- Fix role creation API endpoint not returning id. GitLab issue #390.
|
||||
- Make tags, metadata types and cabinets searchable via the dynamic search API. GitLab issue #344.
|
||||
- Add support for updating configuration options from environment variables.
|
||||
|
||||
2.3 (2017-06-08)
|
||||
================
|
||||
|
||||
@@ -10,3 +10,9 @@ the directory: ``/usr/share/mayan-edms/mayan/settings/local.py``.
|
||||
For a list of all the configuration options, go to "Setup" then "Settings" on
|
||||
your browser. This is also a good place to check if your overrided setting
|
||||
option value in your ``local.py`` file is being interpreted correctly.
|
||||
|
||||
Settings can also be changed via environment variables by prepending the string
|
||||
"MAYAN_" to the configuration name. For example, to change the number of documents
|
||||
displayed per page (COMMON_PAGINATE_BY, by default 40), use::
|
||||
|
||||
MAYAN_COMMON_PAGINATE_BY=10
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
import logging
|
||||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
@@ -85,7 +86,11 @@ class Setting(object):
|
||||
return unicode(self.global_name)
|
||||
|
||||
def cache_value(self):
|
||||
self.raw_value = getattr(settings, self.global_name, self.default)
|
||||
environment_value = os.environ.get('MAYAN_{}'.format(self.global_name))
|
||||
if environment_value:
|
||||
self.raw_value = yaml.safe_load(environment_value)
|
||||
else:
|
||||
self.raw_value = getattr(settings, self.global_name, self.default)
|
||||
self.yaml = Setting.serialize_value(self.raw_value)
|
||||
self.loaded = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user