Eventer

Eventer is a simple event dispaching library.

It provides a simple API to bind and trigger custom named events. Events do not have to be declared before they are bound.

import eventer

def on_edit(page):
    subject = page.path + " is edited"
    sendmail(subject=subject)

eventer.bind("edit", on_edit)

eventer.trigger("edit", page)

The API is inspired by event handling in jQuery and backbone.js.

eventer.bind(event, callback=None)

Binds a callback function to an event.

The callback will be called whenever the specified event is triggered.

def on_edit(page):
    subject = page.path + " is edited"
    sendmail(subject=subject)

eventer.bind("edit", on_edit)

This function can also be used as a decorator.

@eventer.bind("edit")
def on_edit(page):
    subject = page.path + " is edited"
    sendmail(subject=subject)
eventer.unbind(event, callback)

Removes a previously bound callback.

eventer.trigger(event, *args, **kwargs)

Triggers callbacks for the specified event.

Each callback for the specified event is called with args and kwargs passed to this function. Any exception raised by the callback functions is ignored.

Installing

Eventer can be installed from pypi using:

$ pip install eventer

Indices and tables

Table Of Contents

This Page