Initial settings: Refactor setting bootstrapping

Refactor the initial environment settings and configuration file loading
fixing some issues loading Django settings.

Consolidate all database settings into a new single setting
called "DATABASES". This mirrors Django database setting
structure. This changes makes it possible to use configure
multiple databases and database routers from the environment
variables or configuration file.

Remove usage of django-environ. Only a small set of the
features provided by django-environ were being used.
Variable typecasting is now only YAML. YAML parsing
is implemented in code.

Previously the initial setting code added all settings
it found into the global symbol table. Now the settings
found are matched to a explicit list of allowed settings.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-11-27 04:06:21 -04:00
parent 544edea54a
commit ba4858e77f
6 changed files with 84 additions and 44 deletions
+14
View File
@@ -5,6 +5,20 @@ import os
import yaml
from .literals import DJANGO_SETTINGS_LIST
def get_environment_variables():
result = {}
for setting in DJANGO_SETTINGS_LIST:
environment_value = os.environ.get('MAYAN_{}'.format(setting))
if environment_value:
environment_value = yaml_loads(environment_value)
result[setting] = environment_value
return result
def read_configuration_file(path):
try: