You may use a repoze.component registry as an event system. You may register subscribers that will later be notified.
Use the subscribe method of the registry to register an event listener. An event listener is an “adapter” for some number of object types.
from repoze.component import Registry def new_request(request): request.charset = 'ascii' registry = Registry() registry.subscribe(fn, 'request')
Use the notify method of the registry to notify an event listener. An event listener is an adapter for some number of object types, so pass objects with types that the subscriber has been registered for. These will be passed to the subscriber function.
class Request(object): provides('request') request = Request() registry.notify(fn, request)
As a result, any subscribers for the request component type will be called with the request.
To unregister a subscriber, pass the same arguments to the unregister method of a registry that you previously passed to the register method.