[Zope-CVS] CVS: Products/Scheduler - Scheduler.py:1.5

Ken Manheimer klm@zope.com
Thu, 15 Aug 2002 12:51:25 -0400


Update of /cvs-repository/Products/Scheduler
In directory cvs.zope.org:/tmp/cvs-serv19966

Modified Files:
	Scheduler.py 
Log Message:
Tracking refinement of IScheduledEvent to use accessor methods instead
of attributes ('description' => 'getDescription()', 'when' =>
'getTime()') (plus some trivial code layout tweaks).


=== Products/Scheduler/Scheduler.py 1.4 => 1.5 ===
--- Products/Scheduler/Scheduler.py:1.4	Wed Aug 14 15:25:00 2002
+++ Products/Scheduler/Scheduler.py	Thu Aug 15 12:51:24 2002
@@ -123,7 +123,7 @@
             event_service.unsubscribe(self, IScheduler.ITimeEvent)
             # un-receive schedule events that match our id
             event_service.unsubscribe(self, IScheduler.IScheduledEvent,
-                                    filter=self.getFilter())
+                                      filter=self.getFilter())
 
     security.declareProtected(NOTIFY_SCHEDULE_PERM, 'notify')
     def notify(self, event=None):
@@ -186,7 +186,8 @@
                 this_task = this_task.__of__(self)
                 status = this_task() # perform the task
             except:
-                msg = 'The task %s call failed hard!' % this_task.description
+                msg = ('The task %s call failed hard!' %
+                       this_task.getDescription())
                 LOG('Scheduler', ERROR, msg, error=sys.exc_info())
                 continue
 
@@ -199,7 +200,7 @@
                         continue
                 except:
                     msg = ('The task %s next failed hard!' %
-                           this_task.description)
+                           this_task.getDescription())
                     LOG('Scheduler', ERROR, msg, error=sys.exc_info())
                     continue
             try:
@@ -214,8 +215,8 @@
                 continue
 
             msg = ('The task %s declined to reschedule itself '
-                   'by returning %s from its __call__' % 
-                   (this_task.description, str(status)))
+                   'by returning %s from its __call__'
+                   % (this_task.getDescription(), str(status)))
             LOG('Scheduler', BLATHER, msg)
                 
     security.declareProtected(VIEW_SCHEDULE_PERM, 'getPendingTasks')
@@ -230,8 +231,8 @@
             Return a sequence of mappings for use by UI.
         """
         return [ ( x[0], { 'when' : x[1].getTime()
-                       , 'info' : x[1].info()
-                       , 'description' : x[1].description } )
+                       , 'info' : x[1].getInfo()
+                       , 'description' : x[1].getDescription() } )
                  for x in self.getPendingTasks( when ) ]
 
     security.declareProtected(CHANGE_SCHEDULE_PERM, 'schedule')
@@ -316,7 +317,7 @@
         # secondary max_age guard (in case of clock failure)
         if now > self.when + self.max_age:
             msg = ('Task "%s" scheduled for %s failed due to maximum '
-                   'age exceeded' % (self.description,
+                   'age exceeded' % (self.getDescription(),
                                      pretty_time(self.when)))
             LOG('Scheduler', ERROR, msg)
             return 1 # dont schedule a retry, we've failed
@@ -377,6 +378,12 @@
                 LOG('Scheduler', BLATHER, msg)
             return next_time, self.clone(next_time)
         return None # we do not have an interval
+
+    def info(self):
+        return ""
+
+    def getDescription(self):
+        return self.description
 
     def getTime(self):
         return self.when