[Erp5-report] r10468 - /spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Oct 2 11:35:28 CEST 2006


Author: jerome
Date: Mon Oct  2 11:35:26 2006
New Revision: 10468

URL: http://svn.erp5.org?rev=10468&view=rev
Log:
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:
    spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch

Modified: spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch
URL: http://svn.erp5.org/spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch?rev=10468&r1=10467&r2=10468&view=diff
==============================================================================
--- spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch (original)
+++ spec/mandriva/2006.0/zope-TimerService/TimerService-erp5.patch Mon Oct  2 11:35:26 2006
@@ -1,6 +1,8 @@
-diff -Naur TimerService-0.2.orig/TimerService/timerserver/TimerServer.py TimerService-0.2/TimerService/timerserver/TimerServer.py
---- TimerService-0.2.orig/TimerService/timerserver/TimerServer.py	2004-03-17 11:59:42.000000000 +0100
-+++ TimerService-0.2/TimerService/timerserver/TimerServer.py	2006-08-16 15:59:04.135826728 +0200
+Les fichiers TimerService.orig/__init__.pyc et TimerService/__init__.pyc sont différents.
+Les fichiers TimerService.orig/timerserver/__pkginfo__.pyc et TimerService/timerserver/__pkginfo__.pyc sont différents.
+diff -Nur TimerService.orig/timerserver/TimerServer.py TimerService/timerserver/TimerServer.py
+--- TimerService.orig/timerserver/TimerServer.py	2006-10-02 11:00:18.810805750 +0200
++++ TimerService/timerserver/TimerServer.py	2006-10-02 11:00:07.096220000 +0200
 @@ -1,12 +1,12 @@
  # -*- coding: UTF-8 -*-
  # -*- Mode: Python; py-indent-offset: 4 -*-
@@ -59,9 +61,9 @@
  
  class TimerRequest(HTTPRequest):
  
-diff -Naur TimerService-0.2.orig/TimerService/TimerService.py TimerService-0.2/TimerService/TimerService.py
---- TimerService-0.2.orig/TimerService/TimerService.py	2004-03-17 12:22:52.000000000 +0100
-+++ TimerService-0.2/TimerService/TimerService.py	2006-08-16 15:57:43.477088720 +0200
+diff -Nur TimerService.orig/TimerService.py TimerService/TimerService.py
+--- TimerService.orig/TimerService.py	2006-10-02 11:00:17.422025000 +0200
++++ TimerService/TimerService.py	2006-10-02 11:00:13.739955000 +0200
 @@ -1,9 +1,9 @@
  # -*- coding: UTF-8 -*-
  # -*- Mode: Python; py-indent-offset: 4 -*-
@@ -83,7 +85,13 @@
  class TimerService(SimpleItem):
      """ timer service, all objects that wants timer
      event subscribe here """
-@@ -28,7 +30,7 @@
+@@ -24,11 +26,12 @@
+     title = 'TimerService'
+ 
+     security = ClassSecurityInfo()
+-
++    security.declareObjectPublic()
++    
      icon = 'misc_/TimerService/timer_icon.gif'
  
      max_size = 0
@@ -92,7 +100,7 @@
      manage_options = (
          ({'label': 'Subscribers', 'action':'manage_viewSubscriptions'},))
  
-@@ -39,9 +41,9 @@
+@@ -39,44 +42,68 @@
          globals(),
          __name__='manage_viewSubscriptions'
          )
@@ -104,45 +112,61 @@
      def __init__(self, id='timer_service'):
          """ """
          self._subscribers = []
-@@ -49,15 +51,27 @@
- 
+         self._version = 1
+-
++    
++    security.declarePublic('process_timer')
      def process_timer(self, interval):
          """ """
 -        subscriptions = [self.unrestrictedTraverse(path)
 -                         for path in self._subscribers]
+-
+-        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:
+-                subscriber.process_timer(
+-                    interval, DateTime(tick), DateTime(prev_tick), DateTime(next_tick))
+-            except:
+-                LOG('TimerService', ERROR, 'Process timer error', error = sys.exc_info())
 +        # 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
-+
-+        # 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 = []
++            return
 +        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:
-                 subscriber.process_timer(
-@@ -65,18 +79,24 @@
-             except:
-                 LOG('TimerService', ERROR, 'Process timer error', error = sys.exc_info())
- 
-+        # When processing is done, release the lock
-+        processing_lock.release()
-+
++          # 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
++
++          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):
          """ """
          path = '/'.join(ob.getPhysicalPath())
@@ -155,6 +179,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:
@@ -164,7 +190,7 @@
      def unsubscribe(self, ob):
          """ """
          path = '/'.join(ob.getPhysicalPath())
-@@ -85,7 +105,7 @@
+@@ -85,21 +112,23 @@
          if path in subscribers:
              subscribers.remove(path)
              self._subscribers = subscribers
@@ -173,8 +199,12 @@
      security.declareProtected(
          Permissions.view_management_screens, 'lisSubscriptions')
      def lisSubscriptions(self):
-@@ -94,12 +114,12 @@
- 
+         """ """
+         return self._subscribers
+-
++    
++    security.declareProtected(
++        Permissions.view_management_screens, 'manage_removeSubscriptions')
      def manage_removeSubscriptions(self, no, REQUEST=None):
          """ """
 -        subs = self.listAllSubscriptions()
@@ -189,3 +219,4 @@
  
          if REQUEST is not None:
              REQUEST.RESPONSE.redirect('manage_viewSubscriptions')
+Les fichiers TimerService.orig/TimerService.pyc et TimerService/TimerService.pyc sont différents.




More information about the Erp5-report mailing list