Skip to content

Commit

Permalink
Allow plugins to define multiple blueprints
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
alycejenni authored and tino097 committed Nov 29, 2018
1 parent 6f3ee78 commit 9f1d0dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ckan/config/middleware/flask_app.py
Expand Up @@ -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():
Expand Down

0 comments on commit 9f1d0dd

Please sign in to comment.