circuits.core.events – Events

This module defines the basic Event class and common events.

Classes

class circuits.core.events.Event(*args, **kwargs)

Bases: circuits.core.events.BaseEvent

An Event is a message send to one or more channels. It is eventually dispatched to all components that have handlers for one of the channels and the event type.

All normal arguments and keyword arguments passed to the constructor of an event are passed on to the handler. When declaring a handler, its argument list must therefore match the arguments used for creating the event.

Every event has a name attribute that is used for matching the event with the handlers. By default, the name is the uncameled class name of the event.

Variables:
  • channels

    an optional attribute that may be set before firing the event. If defined (usually as a class variable), the attribute specifies the channels that the event should be delivered to as a tuple. This overrides the default behavior of sending the event to the firing component’s channel.

    When an event is fired, the value in this attribute is replaced for the instance with the channels that the event is actually sent to. This information may be used e.g. when the event is passed as a parameter to a handler.

  • value – this is a circuits.core.values.Value object that holds the results returned by the handlers invoked for the event.
  • success – if this optional attribute is set to True, an associated event EventSuccess (original name with “Success” appended) will automatically be fired when all handlers for the event have been invoked successfully.
  • success_channels – the success event is, by default, delivered to same channels as the successfully dispatched event itself. This may be overridden by specifying an alternative list of destinations using this attribute.
  • complete – if this optional attribute is set to True, an associated event EventComplete (original name with “Complete” appended) will automatically be fired when all handlers for the event and all events fired by these handlers (recursively) have been invoked successfully.
  • success_channels – the complete event is, by default, delivered to same channels as the initially dispatched event itself. This may be overridden by specifying an alternative list of destinations using this attribute.

Components

none

Events

class circuits.core.events.Error(type, value, traceback, handler=None)

Bases: circuits.core.events.Event

Error Event

This Event is sent for any exceptions that occur during the execution of an Event Handler that is not SystemExit or KeyboardInterrupt.

Parameters:
  • type (type) – type of exception
  • value (exceptions.TypeError) – exception object
  • traceback (traceback) – traceback of exception
  • kwargs (dict) – (Optional) Additional Information
class circuits.core.events.Failure(*args, **kwargs)

Bases: circuits.core.events.DerivedEvent

Failure Event

This Event is sent when an error has occurred with the execution of an Event Handlers.

Parameters:event (Event) – The event that failed
class circuits.core.events.Registered(component, manager)

Bases: circuits.core.events.Event

Registered Event

This Event is sent when a Component has registered with another Component or Manager. This Event is only sent iif the Component or Manager being registered with is not itself.

Parameters:
  • component (Component) – The Component being registered
  • manager (Component or Manager) – The Component or Manager being registered with
class circuits.core.events.Signal(signal, stack)

Bases: circuits.core.events.Event

Signal Event

This Event is sent when a Component receives a signal.

Parameters:
  • signal – The signal number received.
  • stack – The interrupted stack frame.
class circuits.core.events.Started(component)

Bases: circuits.core.events.Event

Started Event

This Event is sent when a Component has started running.

Parameters:component (Component or Manager) – The component that was started
class circuits.core.events.Stopped(component)

Bases: circuits.core.events.Event

Stopped Event

This Event is sent when a Component has stopped running.

Parameters:component (Component or Manager) – The component that has stopped
class circuits.core.events.Success(*args, **kwargs)

Bases: circuits.core.events.DerivedEvent

Success Event

This Event is sent when all handlers (for a particular event) have been executed successfully, see Manager.

Parameters:event (Event) – The event that has completed.
class circuits.core.events.Unregister(component=None)

Bases: circuits.core.events.Event

Unregister Event

This Event ask for a Component to unregister from its Component or Manager.

class circuits.core.events.Unregistered(component, manager)

Bases: circuits.core.events.Event

Unregistered Event

This Event is sent when a Component has been unregistered from its Component or Manager.

Functions

none