Package muntjac :: Package event
[hide private]
[frames] | no frames]

Source Code for Package muntjac.event

 1  """Provides classes and interfaces for the inheritable event model. The model 
 2  supports inheritable events and a flexible way of registering and unregistering 
 3  event listeners. It's a fundamental building block of Muntjac, and as it is 
 4  included in L{muntjac.ui.abstract_component.AbstractComponent}, all UI 
 5  components automatically support it. 
 6   
 7  Package Specification 
 8  ===================== 
 9   
10  The core of the event model is the inheritable event class hierarchy, and the 
11  L{EventRouter} which provide a simple, ubiquitous mechanism to transport events 
12  to all interested parties. 
13   
14  The power of the event inheritance arises from the possibility of receiving not 
15  only the events of the registered type, I{but also the ones which are inherited 
16  from it}. For example, let's assume that there are the events C{GeneralEvent} 
17  and C{SpecializedEvent} so that the latter inherits the former. Furthermore we 
18  have an object C{A} which registers to receive C{GeneralEvent} type events from 
19  the object C{B}. C{A} would of course receive all C{GeneralEvent}s generated by 
20  C{B}, but in addition to this, C{A} would also receive all C{SpecializedEvent}s 
21  generated by C{B}. However, if C{B} generates some other events that do not 
22  have C{GeneralEvent} as an ancestor, C{A} would not receive them unless it 
23  registers to listen for them, too. 
24   
25  The interface to attaching and detaching listeners to and from an object 
26  works with methods. One specifies the event that should trigger the listener, 
27  the trigger method that should be called when a suitable event occurs and the 
28  object owning the method. From these a new listener is constructed and added 
29  to the event router of the specified component. 
30   
31  The interface is defined in L{MethodEventSource}, and a straightforward 
32  implementation of it is defined in L{EventRouter} which also includes a method 
33  to actually fire the events. 
34   
35  All fired events are passed to all registered listeners, which are of type 
36  L{ListenerMethod}. The listener then checks if the event type matches with the 
37  specified event type and calls the specified trigger method if it does.""" 
38