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
# return possible transition id list:
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,
'setStatePermissionRolesDict')
def setStatePermissionRolesDict(self, permission_roles):
......@@ -141,12 +131,6 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
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,
'getAvailableTypeList')
def getAvailableTypeList(self):
......
......@@ -227,15 +227,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
state = self._getWorkflowStateOf(document, id_only=False)
if state is not None:
state_permission_list = state.getAcquirePermissionList()
for permission, role_list in state.getStatePermissionRolesDict().items():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if permission in state_permission_list:
role_list = list(role_list)
else:
role_list = tuple(role_list)
if modifyRolesForPermission(document, permission, role_list):
changed = True
if hasattr(state, 'getStatePermissionRolesDict'):
for permission, role_list in state.getStatePermissionRolesDict().items():
# tuple means "don't acquire" in zope internal security and list
# is used when acquisition should be done
if permission in state_permission_list:
role_list = list(role_list)
else:
role_list = tuple(role_list)
if modifyRolesForPermission(document, permission, role_list):
changed = True
return changed
# This method allows to update all objects using one workflow, for example
......
......@@ -255,15 +255,9 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
return wfh.get(wf_id, None)
return ()
def decodeWorkflowUid(self, uid):
return cPickle.loads(b64decode(uid))
def encodeWorkflowUid(self, id):
def _encodeWorkflowUid(self, id):
return b64encode(cPickle.dumps(id))
def getObjectFromPath(self, path):
return self.unrestrictedTraverse(path)
security.declareProtected(Permissions.AccessContentsInformation,
'getWorkflowTempObjectList')
def getWorkflowTempObjectList(self, temp_obj=1):
......@@ -308,7 +302,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
new_id = dc_workflow.id
else:
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')
workflow = self.newContent(id=new_id, temp_object=is_temporary,
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