From b2fc5a6fcdd7d8974ad6b80e52d1e4f3fc4f1c33 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Sat, 8 Apr 2017 02:51:28 -0400 Subject: [PATCH] improving get_config (#240) --- CTFd/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CTFd/utils.py b/CTFd/utils.py index b86e2098..2d13bdee 100644 --- a/CTFd/utils.py +++ b/CTFd/utils.py @@ -361,6 +361,18 @@ def delete_file(filename): @cache.memoize() def get_config(key): + with app.app_context(): + value = app.config.get(key) + if value: + if value and value.isdigit(): + return int(value) + elif value and isinstance(value, six.string_types): + if value.lower() == 'true': + return True + elif value.lower() == 'false': + return False + else: + return value config = Config.query.filter_by(key=key).first() if config and config.value: value = config.value