Commit 43b1ae1b authored by Romain Courteaud's avatar Romain Courteaud

Directly use WorkflowTool to access time value.

parent 1ec72363
...@@ -102,6 +102,8 @@ import zope.interface ...@@ -102,6 +102,8 @@ import zope.interface
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from zLOG import LOG, INFO, ERROR, WARNING from zLOG import LOG, INFO, ERROR, WARNING
from DateTime import DateTime
_MARKER = [] _MARKER = []
global registered_workflow_method_set global registered_workflow_method_set
...@@ -3163,22 +3165,21 @@ class Base( CopyContainer, ...@@ -3163,22 +3165,21 @@ class Base( CopyContainer,
portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow') portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow')
wf = portal_workflow.getWorkflowById('edit_workflow') wf = portal_workflow.getWorkflowById('edit_workflow')
wf_list = list(portal_workflow.getWorkflowsFor(self)) wf_list = list(portal_workflow.getWorkflowsFor(self))
getStatusOf = portal_workflow.getStatusOf
if wf is not None: if wf is not None:
wf_list = [wf] + wf_list wf_list = [wf] + wf_list
max_date = None max_date = None
for wf in wf_list: for wf in wf_list:
try: status = getStatusOf(wf.id, self)
history = wf.getInfoFor(self, 'history', None) if status is not None and status.has_key('time'):
except KeyError: date = status['time']
history = None
# as WorkflowHistoryList.__len__ implementation has to walk whole
# workflow check that there is something in history in simpler way
if isinstance(history, list) and history:
date = history[-1].get('time', None)
# Then get the last line of edit_workflow
if date > max_date: if date > max_date:
max_date = date max_date = date
# Return a copy of history time, to prevent modification
if max_date is None:
return max_date return max_date
else:
return DateTime(max_date)
# Layout management # Layout management
security.declareProtected(Permissions.AccessContentsInformation, 'getApplicableLayout') security.declareProtected(Permissions.AccessContentsInformation, 'getApplicableLayout')
......
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