[Erp5-report] r11931 - /erp5/trunk/products/TimerService/TimerService.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 8 15:35:25 CET 2007


Author: kevin
Date: Mon Jan  8 15:35:24 2007
New Revision: 11931

URL: http://svn.erp5.org?rev=11931&view=rev
Log:
Last patch (see http://svn.erp5.org?rev=10468&view=rev for details):
 * make TimerService.process_timer public to shut up VerboseSecurity messages,
 * use finally to release the lock in TimerService.process_timer,
 * reraise all exceptions from suscriber.process_timer.

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

Modified: erp5/trunk/products/TimerService/TimerService.py
URL: http://svn.erp5.org/erp5/trunk/products/TimerService/TimerService.py?rev=11931&r1=11930&r2=11931&view=diff
==============================================================================
--- erp5/trunk/products/TimerService/TimerService.py (original)
+++ erp5/trunk/products/TimerService/TimerService.py Mon Jan  8 15:35:24 2007
@@ -26,7 +26,8 @@
     title = 'TimerService'
 
     security = ClassSecurityInfo()
-
+    security.declareObjectPublic()
+    
     icon = 'misc_/TimerService/timer_icon.gif'
 
     max_size = 0
@@ -48,39 +49,43 @@
         """ """
         self._subscribers = []
         self._version = 1
-
+    
+    security.declarePublic('process_timer')
     def process_timer(self, interval):
         """ """
         # Try to acquire a lock, to make sure we only run one processing at a
         # time, and abort if another processing is currently running
         acquired = processing_lock.acquire(0)
         if not acquired:
-          return
+            return
+        try:
+          # 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
 
-        # 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
 
-        tick = time.time()
-        prev_tick = tick - interval
-        next_tick = tick + interval
-
-        for subscriber in subscriptions:
-            try:
-                subscriber.process_timer(
-                    interval, DateTime(tick), DateTime(prev_tick), DateTime(next_tick))
-            except:
-                LOG('TimerService', ERROR, 'Process timer error', error = sys.exc_info())
-
-        # When processing is done, release the lock
-        processing_lock.release()
+          for subscriber in subscriptions:
+              try:
+                  subscriber.process_timer(
+                      interval, DateTime(tick),
+                      DateTime(prev_tick), DateTime(next_tick))
+              except:
+                  LOG('TimerService', ERROR, 'Process timer error',
+                      error = sys.exc_info())
+                  raise
+        finally:
+            # When processing is done, release the lock
+            processing_lock.release()
 
     def subscribe(self, ob):
         """ """
@@ -91,6 +96,8 @@
             subscribers.append(path)
             self._subscribers = subscribers
 
+    security.declareProtected(
+        Permissions.view_management_screens, 'unsubscribeByPath')
     def unsubscribeByPath(self, path):
         subscribers = self._subscribers
         if path in subscribers:
@@ -111,7 +118,9 @@
     def lisSubscriptions(self):
         """ """
         return self._subscribers
-
+    
+    security.declareProtected(
+        Permissions.view_management_screens, 'manage_removeSubscriptions')
     def manage_removeSubscriptions(self, no, REQUEST=None):
         """ """
         subs = self.lisSubscriptions()




More information about the Erp5-report mailing list