Improve how settings are loaded from config file
Update the way settings are loaded. Instead of loading the entire config file now settings are loaded from the config file on demand when the cache misses. Improve the smart settings classes tests and add another test for the config file loading. Add support for variable config file path. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -13,6 +13,8 @@ from django.conf import settings
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.encoding import force_text, python_2_unicode_compatible
|
||||
|
||||
from .utils import read_configuration_file
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -173,7 +175,13 @@ class Setting(object):
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.raw_value = getattr(settings, self.global_name, self.default)
|
||||
self.raw_value = read_configuration_file(
|
||||
path=settings.CONFIGURATION_FILEPATH
|
||||
).get(
|
||||
self.global_name, 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