From 9f1d0dde9b1ae5fea5a88e5b79d6cb9b203602ba Mon Sep 17 00:00:00 2001 From: Alice Butcher Date: Thu, 11 Oct 2018 18:04:35 +0100 Subject: [PATCH] Allow plugins to define multiple blueprints If `IBlueprint.get_blueprint()` returns a list, register the `Blueprint` objects in a loop. Backwards compatible; will still work if the method only returns a single `Blueprint`. --- ckan/config/middleware/flask_app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ckan/config/middleware/flask_app.py b/ckan/config/middleware/flask_app.py index 2ecbb981287..2a6d8ce86b3 100644 --- a/ckan/config/middleware/flask_app.py +++ b/ckan/config/middleware/flask_app.py @@ -178,7 +178,11 @@ def hello_world_post(): # Set up each IBlueprint extension as a Flask Blueprint for plugin in PluginImplementations(IBlueprint): if hasattr(plugin, 'get_blueprint'): - app.register_extension_blueprint(plugin.get_blueprint()) + plugin_blueprints = plugin.get_blueprint() + if not isinstance(plugin_blueprints, list): + plugin_blueprints = [plugin_blueprints] + for blueprint in plugin_blueprints: + app.register_extension_blueprint(blueprint) # Set flask routes in named_routes for rule in app.url_map.iter_rules():