Home | Trees | Indices | Help |
|
---|
|
object --+ | Dispatcher
Utility class for dispatching events to handlers. Events have to be registered before they can be dispatched or have handlers added to them. Handlers can have an owner associated with them, usually you'll use the reference of the listener. This allows you to remove all the handlers of a specific owner, which should save you some work. Instance methods: - `add_handler`: Add handler for an event - `remove_handlers`: Remove all or some handlers - `remove_handler`: Remove a handler - `dispatch`: Dispatch an event - `register_events`: Register events - `has_event`: Check whether event is supported Instance properties: - `events`: Read-only, set of all supported events Instance decorators: - `event`: Register decorated as a handler Class invariants: - For every (owner, event), there can be only 0 or 1 handlers
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
|
|
|||
_delegator_factory = <pytilities.delegation.delegatorfactory.D
|
|
|||
events Read-only, set of all supported events |
|||
Inherited from |
|
Construct a delegator with a stored `Profile`. Parameters: `profile_name` :: string name of the `Profile` to use to set up the delegator with `target` = None target of the newly created delegator Returns newly created delegator :: Delegator Raises: - `ValueError` when no profile with name `profile_name` exists |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
Add a new delegator factory `Profile` to the factory. Parameters: `name` :: string name of the profile `profile` :: Profile the profile to add |
Add handler for an event, optionally with an owner. Parameters: event_name :: string name of the event to add the handler to handler :: callable the handler to call when the event is dispatched owner = None owner of the handler. Use this reference to easily remove all your handlers from the dispatcher (e.g. remove all handlers with the same owner) Raises: - `UnsupportedEventError` when `event_name` doesn't exist |
Dispatch an event to its handlers. The handlers are executed in a random order. Parameters: event_name :: string name of the event to dispatch args arguments to pass to the handlers keyword_args keyword arguments to pass to the handlers Raises: - `UnsupportedEventError` when `event_name` doesn't exist |
Register the decorated as a handler of `event_name` Parameters: event_name :: string name of the event owner = None owner of the handler. Use this reference to easily remove all your handlers from the dispatcher (e.g. remove all handlers with the same owner) |
Checks if `event_name` is supported Parameters: event_name :: string name of the event Returns True if the dispatcher has the event |
Register events. Parameters: event_names :: (string...) names of events to support |
Remove a handler from an event. It is an error to try to remove a handler from an event that doesn't have this handler attached to it. Parameters: event_name :: string name of the event to which the handler belongs handler :: callable the handler that is attached to the event owner = None owner of the handler Preconditions: 1. `handler` is attached to `event_name` Raises: - `UnsupportedEventError` when `event_name` doesn't exist |
Remove all or some handlers of the dispatcher. `event_name` and `owner` act as filters of what to remove. If no handler matched the criterea, the method will return silently. Parameters: event_name :: string = None the event of which to remove the handlers. `None` means any owner = None the owner of which to remove the handlers. `None` means any |
|
_delegator_factory
|
|
eventsRead-only, set of all supported events Returns ::frozenset(string...)
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Mon Jul 19 11:49:29 2010 | http://epydoc.sourceforge.net |