From eff5952641a6e03f6d910f688985e75824d7422c Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 4 Dec 2017 08:19:51 -0800 Subject: [PATCH] Alternate PR to #3970 (#3997) --- superset/__init__.py | 6 ++++++ superset/config.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/superset/__init__.py b/superset/__init__.py index 099edc133e152..c96fea8d572c9 100644 --- a/superset/__init__.py +++ b/superset/__init__.py @@ -160,4 +160,10 @@ def index(self): module_datasource_map.update(app.config.get('ADDITIONAL_MODULE_DS_MAP')) ConnectorRegistry.register_sources(module_datasource_map) +# Hook that provides administrators a handle on the Flask APP +# after initialization +flask_app_mutator = app.config.get('FLASK_APP_MUTATOR') +if flask_app_mutator: + flask_app_mutator(app) + from superset import views # noqa diff --git a/superset/config.py b/superset/config.py index 8f9058badacde..e169f12ccc3e1 100644 --- a/superset/config.py +++ b/superset/config.py @@ -322,6 +322,12 @@ class CeleryConfig(object): CONFIG_PATH_ENV_VAR = 'SUPERSET_CONFIG_PATH' +# If a callable is specified, it will be called at app startup while passing +# a reference to the Flask app. This can be used to alter the Flask app +# in whatever way. +# example: FLASK_APP_MUTATOR = lambda x: x.before_request = f +FLASK_APP_MUTATOR = None + # smtp server configuration EMAIL_NOTIFICATIONS = False # all the emails are sent using dryrun