Commit bea4e3d4 authored by iv's avatar iv

ERP5Workflow: PERF: fix list getters on category

parent cc8868b7
......@@ -76,30 +76,42 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject,
PropertySheet.Guard,
)
# following getters are redefined for performance improvements
# they use the categories paths directly and string operations
# instead of traversing from the portal to get the objects
# in order to have their id or value
security.declareProtected(Permissions.AccessContentsInformation,
'getBeforeCommitScriptIdList')
def getBeforeCommitScriptIdList(self):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'before commit script', just get the parent once
and find the script names from the category paths
returns the list of before commit script ids
"""
return [path.split('/')[-1] for path in self.getBeforeCommitScriptList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getBeforeCommitScriptValueList')
def getBeforeCommitScriptValueList(self):
"""
returns the list of before commit script values
"""
parent = self.getParentValue()
return [parent._getOb(path.split('/')[-1])
for path in self.getBeforeCommitScriptList()]
return [parent._getOb(transition_id) for transition_id
in self.getBeforeCommitScriptIdList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getActivateScriptIdList')
def getActivateScriptIdList(self):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'activate script', just get the parent once
and find the script names from the category paths
returns the list of activate script ids
"""
return [path.split('/')[-1] for path in self.getActivateScriptList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getActivateScriptValueList')
def getActivateScriptValueList(self):
"""
returns the list of activate script values
"""
parent = self.getParentValue()
return [parent._getOb(path.split('/')[-1])
for path in self.getActivateScriptList()]
return [parent._getOb(transition_id) for transition_id
in self.getActivateScriptIdList()]
\ No newline at end of file
......@@ -99,6 +99,16 @@ class State(IdAsReferenceMixin("state_", "prefix"), XMLObject, CustomStorageMatr
"""
return [path.split('/')[-1] for path in self.getDestinationList()]
def getDestinationValueList(self):
"""
this getter is redefined to improve performance:
instead of getting all the transition objects from the destination list
to then use their ids, extract the information from the string
"""
parent = self.getParentValue()
return [parent._getOb(destination_id) for destination_id in
self.getDestinationIdList()]
def getTransitions(self):
# return possible transition id list:
return self.getDestinationIdList()
......
......@@ -78,28 +78,42 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject,
PropertySheet.ActionInformation,
)
# following getters are redefined for performance improvements
# they use the categories paths directly and string operations
# instead of traversing from the portal to get the objects
# in order to have their id or value
security.declareProtected(Permissions.AccessContentsInformation,
'getBeforeScriptIdList')
def getBeforeScriptIdList(self):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'before script', just get the parent once
and find the script names from the category paths
returns the list of before script ids
"""
return [self.getParentValue()._getOb(path.split('/')[-1])
for path in self.getBeforeScriptList()]
return [path.split('/')[-1] for path in self.getBeforeScriptList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getBeforeScriptValueList')
def getBeforeScriptValueList(self):
"""
returns the list of before script values
"""
parent = self.getParentValue()
return [parent._getOb(transition_id) for transition_id
in self.getBeforeScriptIdList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getAfterScriptIdList')
def getAfterScriptIdList(self):
"""
redefine this getter for performance improvements:
instead of , from the portal, getting the workflow
and taking its script or transition, and repeting this for
all 'after script', just get the parent once
and find the script names from the category paths
returns the list of after script ids
"""
return [path.split('/')[-1] for path in self.getAfterScriptList()]
security.declareProtected(Permissions.AccessContentsInformation,
'getAfterScriptValueList')
def getAfterScriptValueList(self):
"""
returns the list of after script values
"""
return [self.getParentValue()._getOb(path.split('/')[-1])
for path in self.getAfterScriptList()]
parent = self.getParentValue()
return [parent._getOb(transition_id) for transition_id
in self.getAfterScriptIdList()]
\ No newline at end of file
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