emit (event, **extra)

This method can be used to emit an event that other plugins can hook. The event name is prefixed with the plugin ID.

Example

from lektor.pluginsystem import Plugin


class MyPlugin(Plugin):

    def on_setup_env(self, **extra):
        self.emit('setup', foo=42)

Another plugin can then hook this:

from lektor.pluginsystem import Plugin


class MyPlugin(Plugin):

    def on_my_plugin_setup(self, foo, **extra):
        print('got %s' % foo)

(This assumes the plugin id is set to my-plugin in setup.py)

Comments