API

flask_pluginengine.uses(*plugins)

Adds soft dependencies for a plugin.

This decorator adds the given soft dependencies to the plugin. Multiple soft dependencies can be specified using multiple arguments or by using the decorator multiple times.

Unlike dependencies, the specified plugins will be loaded before the plugin if possible, but if they are not available, the plugin will be loaded anyway.

Parameters:

plugins – plugin names

flask_pluginengine.depends(*plugins)

Adds dependencies for a plugin.

This decorator adds the given dependencies to the plugin. Multiple dependencies can be specified using multiple arguments or by using the decorator multiple times.

Parameters:

plugins – plugin names

flask_pluginengine.render_plugin_template(template_name_or_list, **context)

Renders a template from the plugin’s template folder with the given context.

If the template name contains a plugin name (pluginname:name), that name is used instead of the current plugin’s name.

Parameters:
  • template_name_or_list – the name of the template or an iterable containing template names (the first existing template is used)

  • context – the variables that should be available in the context of the template.

flask_pluginengine.url_for_plugin(endpoint, **values)

Like url_for but prepending plugin to endpoint.

PluginEngine

class flask_pluginengine.PluginEngine(app=None, **kwargs)
load_plugins(app, skip_failed=True)

Load all plugins for an application.

Parameters:
  • app – A Flask application

  • skip_failed – If True, initialize plugins even if some plugins could not be loaded.

Returns:

True if all plugins could have been loaded, False otherwise.

get_failed_plugins(app=None)

Return the list of plugins which could not be loaded.

Parameters:

app – A Flask app. Defaults to the current app.

get_active_plugins(app=None)

Return the currently active plugins.

Parameters:

app – A Flask app. Defaults to the current app.

Returns:

dict mapping plugin names to plugin instances

has_plugin(name, app=None)

Return if a plugin is loaded in the current app.

Parameters:
  • name – Plugin name

  • app – A Flask app. Defaults to the current app.

get_plugin(name, app=None)

Return a specific plugin of the current app.

Parameters:
  • name – Plugin name

  • app – A Flask app. Defaults to the current app.

Plugin

class flask_pluginengine.Plugin(plugin_engine, app)
plugin_context()

Pushes the plugin on the plugin context stack.

classmethod instance()

The Plugin instance used by the current app

classmethod title()

Plugin’s title from the docstring

classmethod description()

Plugin’s description from the docstring

init()

Initializes the plugin at application startup.

Should be overridden in your plugin if you need initialization. Runs inside an application context.