[Erp5-report] r11929 - in /erp5/trunk/products/TimerService: ./ timerserver/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 8 15:33:13 CET 2007


Author: kevin
Date: Mon Jan  8 15:33:11 2007
New Revision: 11929

URL: http://svn.erp5.org?rev=11929&view=rev
Log:
Third patch; See http://svn.erp5.org/?rev=8067&view=rev for details

Modified:
    erp5/trunk/products/TimerService/TimerService.py
    erp5/trunk/products/TimerService/timerserver/TimerServer.py

Modified: erp5/trunk/products/TimerService/TimerService.py
URL: http://svn.erp5.org/erp5/trunk/products/TimerService/TimerService.py?rev=11929&r1=11928&r2=11929&view=diff
==============================================================================
--- erp5/trunk/products/TimerService/TimerService.py (original)
+++ erp5/trunk/products/TimerService/TimerService.py Mon Jan  8 15:33:11 2007
@@ -1,6 +1,6 @@
 # -*- coding: UTF-8 -*-
 # -*- Mode: Python; py-indent-offset: 4 -*-
-# Authors: Nik Kim <fafhrd at legco.biz> 
+# Authors: Nik Kim <fafhrd at legco.biz>
 __version__ = '$Revision: 1.3 $'[11:-2]
 
 import sys, time, threading
@@ -30,7 +30,7 @@
     icon = 'misc_/TimerService/timer_icon.gif'
 
     max_size = 0
-    
+
     manage_options = (
         ({'label': 'Subscribers', 'action':'manage_viewSubscriptions'},))
 
@@ -41,9 +41,9 @@
         globals(),
         __name__='manage_viewSubscriptions'
         )
-    
+
     _version = 0
-    
+
     def __init__(self, id='timer_service'):
         """ """
         self._subscribers = []
@@ -57,14 +57,20 @@
         if not acquired:
           return
 
-        subscriptions = [self.unrestrictedTraverse(path)
-                         for path in self._subscribers]
+        # Don't let TimerService crash when the ERP5Site is not yet existing.
+        # This case append when we create a new Portal: At that step Timer Service start
+        #   to 'ping' the portal before the zope transaction in which the portal is
+        #   created is commited.
+        subscriptions = []
+        try:
+          subscriptions = [self.unrestrictedTraverse(path)
+                           for path in self._subscribers]
+        except KeyError:
+          pass
 
         tick = time.time()
         prev_tick = tick - interval
         next_tick = tick + interval
-
-#        LOG('TimerService', INFO, 'Ttimer tick at %s\n'%time.ctime(tick))
 
         for subscriber in subscriptions:
             try:
@@ -79,9 +85,6 @@
     def subscribe(self, ob):
         """ """
         path = '/'.join(ob.getPhysicalPath())
-
-        #if not ISMTPHandler.isImplementedBy(ob):
-        #    raise ValueError, 'Object not support ISMTPHandler'
 
         subscribers = self._subscribers
         if path not in subscribers:
@@ -102,7 +105,7 @@
         if path in subscribers:
             subscribers.remove(path)
             self._subscribers = subscribers
-    
+
     security.declareProtected(
         Permissions.view_management_screens, 'lisSubscriptions')
     def lisSubscriptions(self):

Modified: erp5/trunk/products/TimerService/timerserver/TimerServer.py
URL: http://svn.erp5.org/erp5/trunk/products/TimerService/timerserver/TimerServer.py?rev=11929&r1=11928&r2=11929&view=diff
==============================================================================
--- erp5/trunk/products/TimerService/timerserver/TimerServer.py (original)
+++ erp5/trunk/products/TimerService/timerserver/TimerServer.py Mon Jan  8 15:33:11 2007
@@ -1,6 +1,6 @@
 # -*- coding: UTF-8 -*-
 # -*- Mode: Python; py-indent-offset: 4 -*-
-# Authors: Nik Kim <fafhrd at legco.biz> 
+# Authors: Nik Kim <fafhrd at legco.biz>
 __version__ = 'TimerServer for Zope 0.1'
 
 import traceback
@@ -96,7 +96,7 @@
 
     def unauthorized(self):
         pass
-        
+
 
 class TimerRequest(HTTPRequest):
 




More information about the Erp5-report mailing list