Commit e1f60932 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.mixin.component: Do not fail when workflow_history is not present.

workflow_history attribute may not exist on bootstrapping (constructInstance),
which leads AttributeError exception, which could have further side-effects
as this is called during dynamic class initialisation.
Also, original code from CMFCore.WorkflowTool, from which this code is
derived for bootstrap reasons, catches KeyError (when history exists,
just not for considered workflow), so follow the same pattern.
Laslty, also catch IndexError in case the workflow history entry would
exist empty - which would be the sign of a broken workflow history.
parent ebeb7cb4
......@@ -199,8 +199,11 @@ class ComponentMixin(PropertyRecordableMixin, Base):
"""
Needed for bootstrap when the WorkflowState Accessor is not defined yet
"""
return aq_base(self).workflow_history[
'component_validation_workflow'][-1]['validation_state']
try:
return aq_base(self).workflow_history[
'component_validation_workflow'][-1]['validation_state']
except (AttributeError, KeyError, IndexError):
return 'draft'
security.declareProtected(Permissions.ModifyPortalContent, 'checkConsistency')
def checkConsistency(self, *args, **kw):
......
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