def test_fail_pluginengine_namespace(flask_app): """ Fail if PLUGINENGINE_NAMESPACE is not defined """ del flask_app.config['PLUGINENGINE_NAMESPACE'] with pytest.raises(Exception) as exc_info: PluginEngine(app=flask_app) assert 'PLUGINENGINE_NAMESPACE' in str(exc_info.value)
def engine(flask_app): return PluginEngine(app=flask_app)
# This file is part of Flask-PluginEngine. # Copyright (C) 2014-2021 CERN # # Flask-PluginEngine is free software; you can redistribute it # and/or modify it under the terms of the Revised BSD License. from flask import render_template from flask_pluginengine import PluginFlask, PluginEngine app = PluginFlask(__name__) app.config['PLUGINENGINE_NAMESPACE'] = 'example' app.config['PLUGINENGINE_PLUGINS'] = ['example_plugin'] plugin_engine = PluginEngine(app=app) plugin_engine.load_plugins(app) active_plugins = plugin_engine.get_active_plugins(app=app).values() for plugin in active_plugins: with plugin.plugin_context(): app.register_blueprint(plugin.get_blueprint()) @app.route('/') def hello(): return render_template('index.html', plugins=active_plugins) if __name__ == '__main__': app.run()
# This file is part of Flask-PluginEngine. # Copyright (C) 2014-2017 CERN # # Flask-PluginEngine is free software; you can redistribute it # and/or modify it under the terms of the Revised BSD License. from flask import render_template from flask_pluginengine import PluginFlask, PluginEngine app = PluginFlask(__name__) app.config['PLUGINENGINE_NAMESPACE'] = 'example' app.config['PLUGINENGINE_PLUGINS'] = ['example_plugin'] plugin_engine = PluginEngine(app=app) plugin_engine.load_plugins(app) active_plugins = plugin_engine.get_active_plugins(app=app).values() for plugin in active_plugins: with plugin.plugin_context(): app.register_blueprint(plugin.get_blueprint()) @app.route('/') def hello(): return render_template('index.html', plugins=active_plugins) if __name__ == '__main__': app.run()