Speed up getCreationDate
/reviewed-on nexedi/erp5!934
Showing
... | @@ -3212,20 +3212,20 @@ class Base( CopyContainer, | ... | @@ -3212,20 +3212,20 @@ class Base( CopyContainer, |
""" | """ | ||
Returns the creation date of the document based on workflow information | Returns the creation date of the document based on workflow information | ||
""" | """ | ||
# Check if edit_workflow defined | try: | ||
portal_workflow = self.getPortalObject().portal_workflow | history_list = aq_base(self).workflow_history | ||
wf = portal_workflow.getWorkflowById('edit_workflow') | except AttributeError: | ||
wf_list = portal_workflow.getWorkflowsFor(self) | pass | ||
if wf is not None: | else: | ||
wf_list = [wf] + wf_list | |||
for wf in wf_list: | |||
try: | try: | ||
history = wf.getInfoFor(self, 'history', None) | return history_list['edit_workflow'][0]['time'] | ||
except KeyError: | except LookupError: | ||
history = None | try: | ||
if history is not None and len(history): | return min(history[0]['time'] | ||
|
|||
# Then get the first line of edit_workflow | for history in history_list.itervalues() | ||
return history[0].get('time', None) | if history) | ||
except ValueError: | |||
pass | |||
if getattr(aq_base(self), 'CreationDate', None) is not None: | if getattr(aq_base(self), 'CreationDate', None) is not None: | ||
return asDate(self.CreationDate()) | return asDate(self.CreationDate()) | ||
return None # JPS-XXX - try to find a way to return a creation date instead of None | return None # JPS-XXX - try to find a way to return a creation date instead of None | ||
... | ... |