Commit 644d0255 authored by Jérome Perrin's avatar Jérome Perrin

process_timer:

  save and restore original security manager
  pass a wrapped user to newSecurityManager
  use finally: construct, remove some commented out LOGs and fix indentation



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11946 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57aee107
......@@ -39,7 +39,10 @@ from Products.ERP5Type.Core.Folder import Folder
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.PythonScripts.Utility import allow_class
from AccessControl import ClassSecurityInfo, Permissions
from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManagement import setSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
from Products.CMFCore.utils import UniqueObject, _getAuthenticatedUser, getToolByName
from Globals import InitializeClass, DTMLFile
from Acquisition import aq_base
......@@ -485,10 +488,11 @@ class ActivityTool (Folder, UniqueObject):
if not acquired:
return
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.getOwner()
user = self.portal_catalog.getWrappedOwner()
newSecurityManager(self.REQUEST, user)
currentNode = self.getCurrentNode()
......@@ -496,11 +500,9 @@ class ActivityTool (Folder, UniqueObject):
# only distribute when we are the distributingNode or if it's empty
if (self.distributingNode == self.getCurrentNode()):
self.distribute(len(self._nodes))
#LOG('CMFActivity:', INFO, 'self.distribute(node_count=%s)' %len(self._nodes))
elif not self.distributingNode:
self.distribute(1)
#LOG('CMFActivity:', INFO, 'distributingNodes empty! Calling distribute(1)')
# SkinsTool uses a REQUEST cache to store skin objects, as
# with TimerService we have the same REQUEST over multiple
......@@ -515,17 +517,13 @@ class ActivityTool (Folder, UniqueObject):
# because processing_node starts form 1
if currentNode in self._nodes:
self.tic(list(self._nodes).index(currentNode)+1)
#LOG('CMFActivity:', INFO, 'self.tic(processing_node=%s)' %str(list(self._nodes).index(currentNode)+1))
elif len(self._nodes) == 0:
self.tic(1)
#LOG('CMFActivity:', INFO, 'Node List is empty! Calling tic(1)')
except:
timerservice_lock.release()
raise
else:
finally:
timerservice_lock.release()
setSecurityManager(old_sm)
security.declarePublic('distribute')
def distribute(self, node_count=1):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment