circuits.core.handlers – Handlers

Handlers

This module define the @handler decorator/function and the HandlesType type.

Events

none

Classes

class circuits.core.handlers.HandlerMetaClass(name, bases, dct)

Handler Meta Class

metaclass used by the Component to pick up any methods defined in the new Component and turn them into Event Handlers by applying the @handlers decorator on them. This is done for all methods defined in the Component that: - Do not start with a single ‘_’. or - Have previously been decorated with the @handlers decorator

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Components

none

Functions

circuits.core.handlers.handler(*channels, **kwargs)

Creates an Event Handler

Decorator to wrap a callable into an Event Handler that listens on a set of channels defined by channels. The type of the Event Handler defaults to “listener”. If kwargs[“filter”] is defined and is True, the Event Handler is defined as a Filter and has priority over Listener Event Handlers. If kwargs[“target”] is defined and is not None, the Event Handler will listen for the spcified channels on the spcified Target Component’s Channel.

Examples:
>>> @handler("foo")
... def foo():
...     pass
>>> @handler("bar", filter=True)
... def bar():
...     pass
>>> @handler("foo", "bar")
... def foobar():
...     pass
>>> @handler("x", target="other")
... def x():
...     pass