Commit 92cfba78 authored by iv's avatar iv

ERP5Workflow: PERF: improve getStatePermissionRolesDict and remove

a few useless methods
parent 4a3f3be4
...@@ -113,16 +113,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr ...@@ -113,16 +113,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
# return possible transition id list: # return possible transition id list:
return self.getDestinationIdList() return self.getDestinationIdList()
security.declareProtected(Permissions.AccessContentsInformation,
'getStatePermissionRolesDict')
def getStatePermissionRolesDict(self):
role_dict = getattr(self, 'state_permission_roles', None)
if role_dict is None:
# PersistentMapping is required to have changes on the dict
# commited in the ZODB
self.state_permission_roles = role_dict = PersistentMapping()
return role_dict
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'setStatePermissionRolesDict') 'setStatePermissionRolesDict')
def setStatePermissionRolesDict(self, permission_roles): def setStatePermissionRolesDict(self, permission_roles):
...@@ -141,12 +131,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr ...@@ -141,12 +131,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
""" """
self.state_permission_roles[permission] = list(roles) self.state_permission_roles[permission] = list(roles)
security.declareProtected(Permissions.AccessContentsInformation,
'getDestinationReferenceList')
def getDestinationReferenceList(self):
return [transition.getReference() for transition
in self.getDestinationValueList()]
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getAvailableTypeList') 'getAvailableTypeList')
def getAvailableTypeList(self): def getAvailableTypeList(self):
......
...@@ -227,15 +227,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -227,15 +227,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state = self._getWorkflowStateOf(document, id_only=False) state = self._getWorkflowStateOf(document, id_only=False)
if state is not None: if state is not None:
state_permission_list = state.getAcquirePermissionList() state_permission_list = state.getAcquirePermissionList()
for permission, role_list in state.getStatePermissionRolesDict().items(): if hasattr(state, 'getStatePermissionRolesDict'):
# tuple means "don't acquire" in zope internal security and list for permission, role_list in state.getStatePermissionRolesDict().items():
# is used when acquisition should be done # tuple means "don't acquire" in zope internal security and list
if permission in state_permission_list: # is used when acquisition should be done
role_list = list(role_list) if permission in state_permission_list:
else: role_list = list(role_list)
role_list = tuple(role_list) else:
if modifyRolesForPermission(document, permission, role_list): role_list = tuple(role_list)
changed = True if modifyRolesForPermission(document, permission, role_list):
changed = True
return changed return changed
# This method allows to update all objects using one workflow, for example # This method allows to update all objects using one workflow, for example
......
...@@ -255,15 +255,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -255,15 +255,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return wfh.get(wf_id, None) return wfh.get(wf_id, None)
return () return ()
def decodeWorkflowUid(self, uid): def _encodeWorkflowUid(self, id):
return cPickle.loads(b64decode(uid))
def encodeWorkflowUid(self, id):
return b64encode(cPickle.dumps(id)) return b64encode(cPickle.dumps(id))
def getObjectFromPath(self, path):
return self.unrestrictedTraverse(path)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getWorkflowTempObjectList') 'getWorkflowTempObjectList')
def getWorkflowTempObjectList(self, temp_obj=1): def getWorkflowTempObjectList(self, temp_obj=1):
...@@ -308,7 +302,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool): ...@@ -308,7 +302,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
new_id = dc_workflow.id new_id = dc_workflow.id
else: else:
new_id = 'converting_' + dc_workflow.id new_id = 'converting_' + dc_workflow.id
uid = self.encodeWorkflowUid(new_id) uid = self._encodeWorkflowUid(new_id)
portal_type = ('Workflow' if workflow_type_id == 'DCWorkflowDefinition' else 'Interaction Workflow') portal_type = ('Workflow' if workflow_type_id == 'DCWorkflowDefinition' else 'Interaction Workflow')
workflow = self.newContent(id=new_id, temp_object=is_temporary, workflow = self.newContent(id=new_id, temp_object=is_temporary,
portal_type=portal_type) portal_type=portal_type)
......
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