Commit 484fd839 authored by iv's avatar iv

ERP5Workflow: perf: support parameter 'state' in isActionSupported

This allows to avoid the call of _getWorkflowStateOf if it was already
done before, and so reduce the number of calls of '_getOb' method.
parent 6f7223dd
...@@ -173,14 +173,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -173,14 +173,16 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
return 0 return 0
security.declarePrivate('isActionSupported') security.declarePrivate('isActionSupported')
def isActionSupported(self, document, action, **kw): def isActionSupported(self, document, action, state=None, **kw):
''' '''
Returns a true value if the given action name Returns a true value if the given action name
is possible in the current state. is possible in the current state.
''' '''
if state is None:
state = self._getWorkflowStateOf(document, id_only=0) state = self._getWorkflowStateOf(document, id_only=0)
if state is None: if state is None:
return 0 return 0
if action in state.getDestinationIdList(): if action in state.getDestinationIdList():
transition = self._getOb(action, None) transition = self._getOb(action, None)
if (transition is not None and if (transition is not None and
......
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