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 All rights reserved. This program and the accompanying materials are made
12 available under the terms of the BSD license which accompanies
13 this distribution, and is available at
14 U{http://www.opensource.org/licenses/bsd-license.php}
15 '''
16
17 import Base
18 from AEInterfaces import *
19
21 '''
22 Event that fires on children changes.
23
24 This class registers its name and whether it should be monitored by default in
25 an L{AEMonitor} using the L{Base.registerEventType} function
26 when this module is first imported. The L{AEMonitor} can use this
27 information to build its menus.
28
29 @ivar por: The L{POR} of the parent
30 @type por: L{POR}
31 @ivar added: True when a child is added, False when removed
32 @type added: boolean
33 @ivar child_por: The L{POR} of added/removed child
34 @type child_por: L{POR}
35 '''
36 Base.registerEventType('ChildrenChange', False)
37 - def __init__(self, por, added, child_por, **kwargs):
38 '''
39 Stores the L{POR}, event name, first and last children (if any) associated
40 with the event.
41 '''
42 Base.AccessEngineEvent.__init__(self, **kwargs)
43 self.por = por
44 self.added = added
45 self.child_por = child_por
46
48 '''
49 Returns a human readable representation of this event including its name,
50 its L{POR}, its event name, and its associated values.
51
52 @return: Information about this event
53 @rtype: string
54 '''
55 name = Base.AccessEngineEvent.__str__(self)
56 return '%s:\n\tPOR: %s\n\tadded: %s\n\tchild_por: %s\n' \
57 %(name, self.por, self.added, self.child_por)
58
59 - def execute(self, tier_manager, **kwargs):
60 '''
61 Contacts the L{TierManager} so it can manage the children change event.
62
63 @param tier_manager: TierManager that will handle the event
64 @type tier_manager: L{TierManager}
65 @param kwargs: Packed references to other managers not of interest here
66 @type kwargs: dictionary
67 @return: Always True to indicate the event executed properly
68 @rtype: boolean
69 '''
70 tier_manager.manageEvent(self)
71 return True
72
74 '''
75 Fetches data out of this L{AEEvent.ChildrenChange} for use by a
76 L{Task.ChildrenTask}.
77
78 @return: Dictionary of parameters to be passed to a
79 L{Task.ChildrenTask} as follows:
80 - por: The L{POR} of the accessible parent
81 - added: True when a child is added, False when removed
82 - child_por: The L{POR} of added/removed child
83 '''
84 if self.child_por.incomplete:
85 self.child_por = IPORFactory(self.child_por).create()
86 return {'por':self.getPOR(), 'added':self.added, 'child_por':self.child_por}
87