Commit c6b48d38 authored by Julien Muchembled's avatar Julien Muchembled

Speed up getCreationDate

/reviewed-on nexedi/erp5!934
parent 2e8be7fc
...@@ -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
portal_workflow = self.getPortalObject().portal_workflow
wf = portal_workflow.getWorkflowById('edit_workflow')
wf_list = portal_workflow.getWorkflowsFor(self)
if wf is not None:
wf_list = [wf] + wf_list
for wf in wf_list:
try: try:
history = wf.getInfoFor(self, 'history', None) history_list = aq_base(self).workflow_history
except KeyError: except AttributeError:
history = None pass
if history is not None and len(history): else:
# Then get the first line of edit_workflow try:
return history[0].get('time', None) return history_list['edit_workflow'][0]['time']
except LookupError:
try:
return min(history[0]['time']
  • WARNING SQLCatalog Failed to call method getCreationDate on <Products.ERP5Catalog.CatalogTool.IndexableObjectWrapper for /erp5/portal_components/extension.erp5.TemplateDocumentConversion>
    Traceback (most recent call last):
      File "product/ZSQLCatalog/SQLCatalog.py", line 264, in __getitem__
        value = value()
      File "product/ERP5Type/Base.py", line 3225, in getCreationDate
        for history in history_list.itervalues()
      File "product/ERP5Type/Base.py", line 3226, in <genexpr>
        if history)
    KeyError: 'time'
  • This was already discussed in !941 (comment 90907)

  • Thanks, I only checked !934 (closed) .

Please register or sign in to reply
for history in history_list.itervalues()
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
......
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