Arena
1.0
A content management system
|
An object that can generate events. More...
Public Member Functions | |
def | __init__ |
Constructor. More... | |
def | init |
Initializer. | |
def | __del__ |
Destructor. | |
def | parseParams |
Parse the specified parameters, looking for named events and setting event handlers as appropriate. More... | |
def | generate |
Generate the named event. | |
def | update |
Update the events generated by the object. | |
def | error |
Generate an error event. More... | |
def | toString |
Construct a string representation of the object. More... | |
def | on |
Set the handler for the specified event. More... | |
def | onMultiple |
Set handlers for multiple events. More... | |
def | handlerFor |
Retrieve the handler for the specified event. More... | |
def | generates |
Determine whether or not the object generates the named event. More... | |
def | __getitem__ |
Retrieve the value of the named property. | |
def | __setitem__ |
Set the value of the named property. | |
Public Member Functions inherited from Library.Base.Classwork.AnObject | |
def | init |
Initialize a new object instance. More... | |
def | __init__ |
Construct and initialize a new instance of AnObject. More... | |
def | __del__ |
Destroy the object instance. More... | |
def | displayName |
Construct a "pretty" display name for the class instance, based on the name of its class. More... | |
def | implements |
Determine whether the class instance is related to the specified class. More... | |
def | toString |
Return a string representation of the class, suitable for output to a console or text-based device. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | classname |
Return the name of the class from which the instance was created. More... | |
def | name |
Return the name of the class. More... | |
Public Member Functions inherited from Library.String.Utilities.IsPrintable | |
def | toString |
Return a string representation of the class conveniently. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | printTo |
Print a string representation of the class to the specified stream. More... | |
An object that can generate events.
When parsing events, this class assumes that the event is named using camel case (i.e., "eventName"). When specifying event handlers as part of the list of parameters passed to the constructor, this class assumes that the event names are prefixed with "on" and the remainder of the event name is given in camel case (i.e., "onEventName"). These assumptions are designed to make code easier to read.
def Library.Base.Events.AnEventfulObject.__init__ | ( | Self, | |
params | |||
) |
Constructor.
The items passed in params
are stored by the class for later use, although the base class itself does not make use of any parameters except where they indicate event handlers.
Handlers for the events generated by the class or its descendants may be passed as part of params
. The handlers are each registered with a call to AnEventfulObject.on(). Each event registered should be prefixed with "on" (i.e., "onInit" for the "init" event); this distinguishes event handlers from the other parameters passed in params
. Event handlers are removed from params
after they have been processed.
def Library.Base.Events.AnEventfulObject.error | ( | Self, | |
Error | |||
) |
Generate an error event.
If an event handler is specified for this event, it will receive an instance of AnEvent with a parameter named Error
that refers to the exception that was raised because of the error. The handler should set Event.handled() to True
in order to prevent the exception from being raised; otherwise, if the event is not handled, an exception will be raised by this routine.
def Library.Base.Events.AnEventfulObject.generates | ( | Self, | |
eventName | |||
) |
Determine whether or not the object generates the named event.
def Library.Base.Events.AnEventfulObject.handlerFor | ( | Self, | |
eventName | |||
) |
Retrieve the handler for the specified event.
If eventName
refers to an event that is not generated by the class, this routine returns None
.
def Library.Base.Events.AnEventfulObject.on | ( | Self, | |
eventName, | |||
newHandler | |||
) |
Set the handler for the specified event.
The newHandler
parameter should refer to a callable object that can receive the event object.
This routine returns the previous handler for the specified event.
def Library.Base.Events.AnEventfulObject.onMultiple | ( | Self, | |
events | |||
) |
Set handlers for multiple events.
The parameters passed in events
should follow the same format as those passed to the constructor for AnEventfulObject: the event to handle should be specified by prefixing the event name with "on".
This method returns a dictionary object that contains the previous handler for each event. Only those events in \ p events which are actually generated by the class will be registered; all other event names are discarded.
def Library.Base.Events.AnEventfulObject.parseParams | ( | Self, | |
params | |||
) |
Parse the specified parameters, looking for named events and setting event handlers as appropriate.
def Library.Base.Events.AnEventfulObject.toString | ( | Self | ) |
Construct a string representation of the object.
This representation uses the format provided in #eoStringRepresentation.