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