Plugin API reference

Indico’s plugin system allows you to extend indico with additional modules which can be installed separately and do not require any modifications to the indico core itself.

class indico.core.plugins.IndicoPlugin(plugin_engine, app)

Bases: flask_pluginengine.plugin.Plugin

Base class for an Indico plugin

All your plugins need to inherit from this class. It extends the Plugin class from Flask-PluginEngine with useful indico-specific functionality that makes it easier to write custom plugins.

When creating your plugin, the class-level docstring is used to generate the friendly name and description of a plugin. Its first line becomes the name while everything else goes into the description.

This class provides methods for some of the more common hooks Indico provides. Additional signals are defined in signals and can be connected to custom functions using connect().

acl_event_settings = frozenset([])

A set containing the names of event-specific settings which store ACLs

acl_settings = frozenset([])

A set containing the names of settings which store ACLs

category = None

The group category that the plugin belongs to

configurable = False

If the plugin should link to a details/config page in the admin interface

default_event_settings = {}

A dictionary containing default values for event-specific settings

default_settings = {}

A dictionary containing default values for settings

default_user_settings = {}

A dictionary containing default values for user-specific settings

event_settings

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

event_settings_converters = {}

A dict containing custom converters for event-specific settings

get_blueprints()

Return blueprints to be registered on the application

A single blueprint can be returned directly, for multiple blueprint you need to yield them or return an iterable.

get_vars_js()

Return a dictionary with variables to be added to vars.js file

init()

Called when the plugin is being loaded/initialized.

If you want to run custom initialization code, this is the method to override. Make sure to call the base method or the other overridable methods in this class will not be called anymore.

inject_css(name, view_class=None, subclasses=True, condition=None)

Injects a CSS bundle into Indico’s pages

Parameters:
  • name – Name of the bundle
  • view_class – If a WP class is specified, only inject it into pages using that class
  • subclasses – also inject into subclasses of view_class
  • condition – a callable to determine whether to inject or not. only called, when the view_class criterion matches
inject_js(name, view_class=None, subclasses=True, condition=None)

Injects a JS bundle into Indico’s pages

Parameters:
  • name – Name of the bundle
  • view_class – If a WP class is specified, only inject it into pages using that class
  • subclasses – also inject into subclasses of view_class
  • condition – a callable to determine whether to inject or not. only called, when the view_class criterion matches
inject_vars_js()

Returns a string that will define variables for the plugin in the vars.js file

register_assets()

Add assets to the plugin’s webassets environment.

In most cases the whole method can consist of calls to register_js_bundle() and register_css_bundle().

register_css_bundle(name, *files)

Registers an SCSS bundle in the plugin’s webassets environment

register_js_bundle(name, *files)

Registers a JS bundle in the plugin’s webassets environment

settings

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

settings_converters = {}

A dict containing custom converters for settings

settings_form = None

WTForm for the plugin’s settings (requires configurable=True). All fields must return JSON-serializable types.

settings_form_field_opts = {}

A dictionary which can contain the kwargs for a specific field in the settings_form.

strict_settings = False

If settings, event_settings and user_settings should use strict mode, i.e. only allow keys in default_settings, default_event_settings or default_user_settings (or the related acl_settings sets)

template_hook(name, receiver, priority=50, markup=True)

Registers a function to be called when a template hook is invoked.

For details see :func:~`indico.web.flask.templating.register_template_hook`

translation_domain

Return the domain for this plugin’s translation_path

translation_path

Return translation files to be used by the plugin. By default, get <root_path>/translations, unless it does not exist

user_settings

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

user_settings_converters = {}

A dict containing custom converters for user-specific settings

class indico.core.plugins.IndicoPluginBlueprint(name, *args, **kwargs)

Bases: flask_pluginengine.mixins.PluginBlueprintMixin, indico.web.flask.wrappers.IndicoBlueprint

The Blueprint class all plugins need to use.

It contains the necessary logic to run the blueprint’s view functions inside the correct plugin context and to make the static folder work.

indico.core.plugins.get_plugin_template_module(template_name, **context)

Like get_template_module(), but using plugin templates

indico.core.plugins.include_plugin_css_assets(bundle_name)

Jinja template function to generate HTML tags for a plugin CSS asset bundle.

indico.core.plugins.include_plugin_js_assets(bundle_name)

Jinja template function to generate HTML tags for a plugin JS asset bundle.

indico.core.plugins.plugin_url_rule_to_js(endpoint)

Like url_rule_to_js() but prepending plugin name prefix to the endpoint

indico.core.plugins.url_for_plugin(endpoint, *targets, **values)

Like url_for() but prepending 'plugin_' to the blueprint name.