From 7c0c71ca6904d819b35a803184340b35f424fbd0 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 7 Feb 2020 15:33:06 -0500 Subject: [PATCH] Auto load any keys/values from the yaml config file. This should allow us to remove all the boilerplate code in this file where a name is pulled from the config dict and put into the top level namespace of the settings module. We do this first so that any logic that adds more complex or dynamic keys will still run and is safe. Now that this is here we can start removing any simple boilerplate. --- cms/envs/production.py | 3 +++ lms/envs/production.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cms/envs/production.py b/cms/envs/production.py index 0b5302de7e..1bd8581cc4 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -38,6 +38,9 @@ CONFIG_FILE = get_env_setting('STUDIO_CFG') with codecs.open(CONFIG_FILE, encoding='utf-8') as f: __config__ = yaml.safe_load(f) + # Add the key/values from config into the global namespace of this module. + vars().update(__config__) + # ENV_TOKENS and AUTH_TOKENS are included for reverse compatability. # Removing them may break plugins that rely on them. ENV_TOKENS = __config__ diff --git a/lms/envs/production.py b/lms/envs/production.py index dcf8a4592d..56dccb4c21 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -50,6 +50,9 @@ CONFIG_FILE = get_env_setting('LMS_CFG') with codecs.open(CONFIG_FILE, encoding='utf-8') as f: __config__ = yaml.safe_load(f) + # Add the key/values from config into the global namespace of this module. + vars().update(__config__) + # ENV_TOKENS and AUTH_TOKENS are included for reverse compatability. # Removing them may break plugins that rely on them. ENV_TOKENS = __config__