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

Source Code for Module AEEvent.TimerAlert

  1  ''' 
  2  Defines an L{AEEvent} indicating a timer event occurred. 
  3   
  4  @author: Peter Parente 
  5  @organization: IBM Corporation 
  6  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
  7  @license: The BSD License 
  8   
  9  All rights reserved. This program and the accompanying materials are made 
 10  available under the terms of the BSD license which accompanies 
 11  this distribution, and is available at 
 12  U{http://www.opensource.org/licenses/bsd-license.php} 
 13  ''' 
 14  import Base 
 15   
16 -class TimerAlert(Base.AccessEngineEvent):
17 ''' 18 Event that fires when a registered timer triggers a notification. 19 20 This class registers its name and whether it should be monitored by default 21 in an L{AEMonitor} using the L{Base.registerEventType} function when 22 this module is first imported. The L{AEMonitor} can use this information to 23 build its menus. 24 25 @ivar aid: Unique identifier for the application L{Tier} with which the 26 timer that fired this event is associated 27 @type aid: opaque 28 @ivar tid: ID of the L{Task} that will handle the timer event 29 @type tid: integer 30 @ivar interval: Interval on which the timer is triggered 31 @type interval: integer 32 ''' 33 Base.registerEventType('TimerAlert', False)
34 - def __init__(self, aid, tid, interval, **kwargs):
35 ''' 36 Stores important references. 37 38 @param aid: Unique identifier for the application L{Tier} with which the 39 timer that fired this event is associated 40 @type aid: opaque 41 @param tid: ID of the L{Task} that will handle the timer event 42 @type tid: integer 43 @param interval: Interval on which the timer is triggered 44 @type interval: integer 45 ''' 46 Base.AccessEngineEvent.__init__(self, focused=False, **kwargs) 47 self.aid = aid 48 self.tid = tid 49 self.interval = interval
50
51 - def __str__(self):
52 ''' 53 Returns a human readable representation of this event including its name 54 and interval. 55 56 @return: Information about this event 57 @rtype: string 58 ''' 59 name = Base.AccessEngineEvent.__str__(self) 60 return '%s:\n\tinterval: %d' % (name, self.interval)
61
62 - def execute(self, tier_manager, **kwargs):
63 ''' 64 Contacts the L{TierManager} and asks it to manage this chooser event. 65 66 @param tier_manager: TierManager that will handle the event 67 @type tier_manager: L{TierManager} 68 @param kwargs: Packed references to other managers not of interest here 69 @type kwargs: dictionary 70 @return: True to indicate the event executed properly 71 @rtype: boolean 72 ''' 73 tier_manager.manageTimer(self) 74 return True
75
76 - def getAppID(self):
77 ''' 78 @return: Unique application ID identifying the top most container for the 79 source of this event (i.e. the application) 80 @rtype: opaque object 81 ''' 82 return self.aid
83
84 - def getTaskKey(self):
85 ''' 86 Gets the ID of the L{Task} that should handle the timer event. This 87 information is used to locate the L{Task} that should handle this event. 88 89 @return: ID of the L{Task} that will handle the event 90 @rtype: integer 91 ''' 92 return self.tid
93
94 - def getDataForTask(self):
95 ''' 96 Fetches data out of this L{TimerAlert} for use by a L{Task.TimerTask}. 97 98 @return: Dictionary of parameters to be passed to a L{Task.TimerTask} as 99 follows: 100 - interval: The interval on which the timer fires 101 @rtype: dictionary 102 ''' 103 return {'interval' : self.interval}
104