Package AccessEngine :: Package AEEvent :: Module ChildrenChange
[hide private]
[frames] | no frames]

Source Code for Module AccessEngine.AEEvent.ChildrenChange

 1  ''' 
 2  Defines an L{AEEvent} indicating that a child has been added/removed to an  
 3  accessible. 
 4   
 5  @author: Brett Clippingdale 
 6  @author: Peter Parente 
 7  @organization: IBM Corporation 
 8  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 9  @license: The BSD License 
10   
11  @author: Frank Zenker 
12  @author: Ramona Bunk 
13  @organization: IT Science Center Ruegen gGmbH, Germany 
14  @copyright: Copyright (c) 2007, 2008 ITSC Ruegen 
15  @license: The BSD License 
16   
17  All rights reserved. This program and the accompanying materials are made  
18  available under the terms of the BSD license which accompanies 
19  this distribution, and is available at 
20  U{http://www.opensource.org/licenses/bsd-license.php} 
21  ''' 
22   
23  import AccessEngine 
24  import Base 
25  from AccessEngine.AEAccInterfaces import * 
26   
27 -class ChildrenChange(Base.AEEvent):
28 ''' 29 Event that fires on children changes. 30 31 This class registers its name and whether it should be monitored by default in 32 an L{AEMonitor} using the L{Base.registerEventType} function 33 when this module is first imported. The L{AEMonitor} can use this 34 information to build its menus. 35 36 @ivar por: The L{AEPor} of the parent 37 @type por: L{AEPor} 38 @ivar added: True when a child is added, False when removed 39 @type added: boolean 40 @ivar child_por: The L{AEPor} of added/removed child 41 @type child_por: L{AEPor} 42 ''' 43 Base.registerEventType('ChildrenChange', False)
44 - def __init__(self, por, added, child_por, **kwargs):
45 ''' 46 Stores the L{AEPor}, event name, first and last children (if any) associated 47 with the event. 48 ''' 49 Base.AEEvent.__init__(self, **kwargs) 50 self.por = por 51 self.added = added 52 self.child_por = child_por
53
54 - def __str__(self):
55 ''' 56 Returns a human readable representation of this event including its name, 57 its L{AEPor}, its event name, and its associated values. 58 59 @return: Information about this event 60 @rtype: string 61 ''' 62 name = Base.AEEvent.__str__(self) 63 return '%s:\n\tPOR: %s\n\tadded: %s\n\tchild_por: %s\n' \ 64 %(name, self.por, self.added, self.child_por)
65
66 - def execute(self):
67 ''' 68 Contacts the L{AETierManager} so it can manage the children change event. 69 70 @return: Always True to indicate the event executed properly 71 @rtype: boolean 72 ''' 73 AccessEngine.AETierManager.manageEvent(self) 74 return True
75
76 - def getDataForTask(self):
77 ''' 78 Fetches data out of this L{AEEvent.ChildrenChange} for use by a 79 L{AEScript.EventScript.onChildrenChange}. 80 81 @return: Dictionary of parameters to be passed to a 82 L{AEScript.EventScript.onChildrenChange} as follows: 83 - por: The L{AEPor} of the accessible parent 84 - added: True when a child is added, False when removed 85 - child_por: The L{AEPor} of added/removed child 86 ''' 87 if self.child_por.incomplete: 88 self.child_por = IPORFactory(self.child_por).create() 89 return {'por':self.getPOR(), 'added':self.added, 'child_por':self.child_por}
90