From c4c25ff198be6c266cbd17958e9708d83da0c0f7 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 3 Mar 2017 15:13:45 -0800 Subject: [PATCH 1/3] Allowing environments to import Blueprints --- superset/__init__.py | 8 ++++++++ superset/config.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/superset/__init__.py b/superset/__init__.py index f3d8795c02d45..bad241e3fccb0 100644 --- a/superset/__init__.py +++ b/superset/__init__.py @@ -29,6 +29,14 @@ app.config.from_object(CONFIG_MODULE) conf = app.config +for bp in conf.get('BLUEPRINTS'): + try: + print("Registering blueprint: '{}'".format(bp.name)) + app.register_blueprint(bp) + except Exception as e: + print("blueprint registration failed") + logging.exception(e) + if conf.get('SILENCE_FAB'): logging.getLogger('flask_appbuilder').setLevel(logging.ERROR) diff --git a/superset/config.py b/superset/config.py index 293fa485cdfb7..b2bc460c4f430 100644 --- a/superset/config.py +++ b/superset/config.py @@ -286,6 +286,11 @@ class CeleryConfig(object): # permission management SILENCE_FAB = True + +# Integrate external Blueprints to the app by passing them to your +# configuration. These blueprints will get integrated in the app +BLUEPRINTS = [] + try: if CONFIG_PATH_ENV_VAR in os.environ: # Explicitly import config module that is not in pythonpath; useful From 473a8c88b1828d5ec11147db75b8c44432b653df Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 3 Mar 2017 15:22:08 -0800 Subject: [PATCH 2/3] Docs entry --- docs/installation.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/installation.rst b/docs/installation.rst index e6aaa5fa9e9a2..796637a04a6e4 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -377,3 +377,28 @@ your environment.:: npm run build cd $SUPERSET_HOME python setup.py install + + +Blueprints +---------- + +`Blueprints are Flask's reusable apps `_. +Superset allows you to specify +pass an array of Blueprints in your ``superset_config`` module. Here's +an example on how this can work with an simple Blueprint. By doing +so, you can expect Superset to serve a page that says "OK" +at the ``/simple_page`` url. This can allow you to run other things such +as custom data visualization applications alongside Superset, on the +same server. + +..code :: + + from flask import Blueprint + simple_page = Blueprint('simple_page', __name__, + template_folder='templates') + @simple_page.route('/', defaults={'page': 'index'}) + @simple_page.route('/') + def show(page): + return "Ok" + + BLUEPRINTS = [simple_page] From a7f14c26d17f11f587de21f3951e7d0bb0f09002 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 3 Mar 2017 17:09:11 -0800 Subject: [PATCH 3/3] Fix typos --- docs/installation.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/installation.rst b/docs/installation.rst index 796637a04a6e4..e85fd01765356 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -383,9 +383,9 @@ Blueprints ---------- `Blueprints are Flask's reusable apps `_. -Superset allows you to specify -pass an array of Blueprints in your ``superset_config`` module. Here's -an example on how this can work with an simple Blueprint. By doing +Superset allows you to specify an array of Blueprints +an array of Blueprints in your ``superset_config`` module. Here's +an example on how this can work with a simple Blueprint. By doing so, you can expect Superset to serve a page that says "OK" at the ``/simple_page`` url. This can allow you to run other things such as custom data visualization applications alongside Superset, on the