Package AEEvent :: Module StateChange
[hide private]
[frames] | no frames]

Source Code for Module AEEvent.StateChange

 1  ''' 
 2  Defines an L{AEEvent} indicating that the state of an accessible or an item 
 3  changed. 
 4   
 5  @author: Peter Parente 
 6  @organization: IBM Corporation 
 7  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 8  @license: The BSD License 
 9   
10  All rights reserved. This program and the accompanying materials are made  
11  available under the terms of the BSD license which accompanies 
12  this distribution, and is available at 
13  U{http://www.opensource.org/licenses/bsd-license.php} 
14  ''' 
15   
16  import Base 
17   
18 -class StateChange(Base.AccessEngineEvent):
19 ''' 20 Event that fires when the state of an accessible or item changes. 21 22 This class registers its name and whether it should be monitored by default in 23 an L{AEMonitor} using the L{Base.registerEventType} function 24 when this module is first imported. The L{AEMonitor} can use this 25 information to build its menus. 26 27 @ivar name: Name of the property that changed 28 @type name: string 29 @ivar value: The new text associated with the property 30 @type value: string 31 ''' 32 Base.registerEventType('StateChange', False)
33 - def __init__(self, por, name, value, **kwargs):
34 ''' 35 Stores the L{POR}, state name, and its new value. 36 37 @param por: Point of regard to the accessible/item whose state changed 38 @type por: L{POR} 39 @param name: Name of the state that changed 40 @type name: string 41 @param value: New value of the state 42 @type value: boolean 43 ''' 44 Base.AccessEngineEvent.__init__(self, **kwargs) 45 self.name = name 46 self.value = value 47 self.por = por
48
49 - def __str__(self):
50 ''' 51 Returns a human readable representation of this event including its name, 52 its L{POR}, its state name, and its new value. 53 54 @return: Information about this event 55 @rtype: string 56 ''' 57 name = Base.AccessEngineEvent.__str__(self) 58 return '%s:\n\tPOR: %s\n\tstate: %s\n\tvalue: %s' % \ 59 (name, self.por, self.name, self.value)
60
61 - def execute(self, tier_manager, **kwargs):
62 ''' 63 Contacts the L{TierManager} so it can manage the property change event. 64 65 @param tier_manager: TierManager that will handle the event 66 @type tier_manager: L{TierManager} 67 @param kwargs: Packed references to other managers not of interest here 68 @type kwargs: dictionary 69 @return: Always True to indicate the event executed properly 70 @rtype: boolean 71 ''' 72 tier_manager.manageEvent(self) 73 return True
74
75 - def getDataForTask(self):
76 ''' 77 Fetches data out of this L{StateChange} for use by a L{Task.StateTask}. 78 79 @return: Dictionary of parameters to be passed to a 80 L{Task.PropertyTask} as follows: 81 - por: The L{POR} of the accessible whose property changed 82 - name: The text name of the property that changed 83 - value: The new value of the state (True or False) 84 @rtype: dictionary 85 ''' 86 return {'por':self.getPOR(), 'name':self.name, 'value':self.value}
87