Commit e30ee4ad authored by iv's avatar iv

ERP5Workflow: PERF: remove categories usage on Workflow and Transition

by redefining getSourceValue (workflow) and getDestinationValue (transition)
parent 6f77913b
...@@ -139,3 +139,16 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject, ...@@ -139,3 +139,16 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject,
parent = self.getParentValue() parent = self.getParentValue()
return [parent._getOb(transition_id) for transition_id return [parent._getOb(transition_id) for transition_id
in self.getAfterScriptIdList()] in self.getAfterScriptIdList()]
def getDestinationValue(self):
"""
returns the destination object
"""
destination_path_list = [path for path in self.getCategoryList()
if path.startswith('destination/')]
if destination_path_list:
destination_id = destination_path_list[0].split('/')[-1]
parent = self.getParentValue()
return parent._getOb(destination_id)
return None
...@@ -61,6 +61,7 @@ from tempfile import mktemp ...@@ -61,6 +61,7 @@ from tempfile import mktemp
from types import StringTypes from types import StringTypes
from zLOG import LOG, INFO, WARNING from zLOG import LOG, INFO, WARNING
ACTIVITY_GROUPING_COUNT = 100 ACTIVITY_GROUPING_COUNT = 100
class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
...@@ -1210,3 +1211,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -1210,3 +1211,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
permission_to_delete.append(permission) permission_to_delete.append(permission)
for permission in permission_to_delete: for permission in permission_to_delete:
del state.state_permission_roles_dict[permission] del state.state_permission_roles_dict[permission]
def getSourceValue(self):
"""
returns the source object
"""
# this function is redefined here for performance reasons:
# avoiding the usage of categories speeds up workflow *a lot*
source_path_list = [path for path in self.getCategoryList()
if path.startswith('source/')]
if source_path_list:
source_id = source_path_list[0].split('/')[-1]
return self._getOb(source_id)
return None
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