[Erp5-report] r19176 - /erp5/trunk/products/CMFActivity/ActivityTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Feb 8 13:56:27 CET 2008


Author: vincent
Date: Fri Feb  8 13:56:26 2008
New Revision: 19176

URL: http://svn.erp5.org?rev=19176&view=rev
Log:
Split security handling and unlocking into 2 separate try..except levels, for the sake of robustness.

Modified:
    erp5/trunk/products/CMFActivity/ActivityTool.py

Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=19176&r1=19175&r2=19176&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityTool.py (original)
+++ erp5/trunk/products/CMFActivity/ActivityTool.py Fri Feb  8 13:56:26 2008
@@ -558,41 +558,43 @@
         if not acquired:
           return
 
-        old_sm = getSecurityManager()
         try:
+          old_sm = getSecurityManager()
           try:
-            # get owner of portal_catalog, so normally we should be able to
-            # have the permission to invoke all activities
-            user = self.portal_catalog.getWrappedOwner()
-            newSecurityManager(self.REQUEST, user)
-
-            currentNode = self.getCurrentNode()
-            self.registerNode(currentNode)
-            processing_node_list = self.getNodeList(role=ROLE_PROCESSING)
-
-            # only distribute when we are the distributingNode or if it's empty
-            if (self.getDistributingNode() == currentNode):
-              self.distribute(len(processing_node_list))
-
-            # SkinsTool uses a REQUEST cache to store skin objects, as
-            # with TimerService we have the same REQUEST over multiple
-            # portals, we clear this cache to make sure the cache doesn't
-            # contains skins from another portal.
-            stool = getToolByName(self, 'portal_skins', None)
-            if stool is not None:
-              stool.changeSkin(None)
-
-            # call tic for the current processing_node
-            # the processing_node numbers are the indices of the elements in the node tuple +1
-            # because processing_node starts form 1
-            if currentNode in processing_node_list:
-              self.tic(processing_node_list.index(currentNode)+1)
-          except:
-            # Catch ALL exception to avoid killing timerserver.
-            LOG('ActivityTool', ERROR, 'process_timer received an exception', error=sys.exc_info())
+            try:
+              # get owner of portal_catalog, so normally we should be able to
+              # have the permission to invoke all activities
+              user = self.portal_catalog.getWrappedOwner()
+              newSecurityManager(self.REQUEST, user)
+
+              currentNode = self.getCurrentNode()
+              self.registerNode(currentNode)
+              processing_node_list = self.getNodeList(role=ROLE_PROCESSING)
+
+              # only distribute when we are the distributingNode or if it's empty
+              if (self.getDistributingNode() == currentNode):
+                self.distribute(len(processing_node_list))
+
+              # SkinsTool uses a REQUEST cache to store skin objects, as
+              # with TimerService we have the same REQUEST over multiple
+              # portals, we clear this cache to make sure the cache doesn't
+              # contains skins from another portal.
+              stool = getToolByName(self, 'portal_skins', None)
+              if stool is not None:
+                stool.changeSkin(None)
+
+              # call tic for the current processing_node
+              # the processing_node numbers are the indices of the elements in the node tuple +1
+              # because processing_node starts form 1
+              if currentNode in processing_node_list:
+                self.tic(processing_node_list.index(currentNode)+1)
+            except:
+              # Catch ALL exception to avoid killing timerserver.
+              LOG('ActivityTool', ERROR, 'process_timer received an exception', error=sys.exc_info())
+          finally:
+            setSecurityManager(old_sm)
         finally:
           timerservice_lock.release()
-          setSecurityManager(old_sm)
 
     security.declarePublic('distribute')
     def distribute(self, node_count=1):




More information about the Erp5-report mailing list