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.
This commit is contained in:
Feanil Patel
2020-02-07 15:33:06 -05:00
parent b6047709b3
commit 7c0c71ca69
2 changed files with 6 additions and 0 deletions

View File

@@ -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__

View File

@@ -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__