Description of the issue/feature this PR addresses
This Pull Request fixes an AttributeError that arises when triggering transitions that were created or updated by using senaite.core.api.workflow because the transition property script_after_name (Script (after)) was wrongly set to 'None':
However, on setProperties, the system stringifies the values and therefore, the value of the attribute becomes 'None' instead:
>>> from senaite.core.api import workflow as wapi
>>> wf = wapi.get_workflow(SAMPLE_WORKFLOW)
>>> # Add a new 'dumb' transition using DCWorkflow
>>> wf.transitions.addTransition("dumb")
>>> dumb = wf.transitions.get("dumb")
>>> getattr(dumb, "after_script_name") is None
True
>>> dumb.setProperties("Dumb", "", after_script_name=None)
>>> getattr(dumb, "after_script_name") is None
False
>>> getattr(dumb, "after_script_name")
'None'
This Pull Request makes senaite.core.api.workflow to be aware of this inconsistent behavior when updating/creating transitions.
Current behavior before PR
The value for attribute after_script_name of transitions updated or created with core's workflow API have a 'None' value (as string)
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 176, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 385, in publish_module
Module ZPublisher.WSGIPublisher, line 288, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 63, in call_object
Module bika.lims.browser.workflow, line 153, in __call__
Module bika.lims.browser.workflow, line 164, in __call__
Module bika.lims.browser.workflow, line 182, in do_action
Module bika.lims.workflow, line 99, in doActionFor
Module Products.CMFCore.WorkflowTool, line 252, in doActionFor
Module Products.CMFCore.WorkflowTool, line 537, in _invokeWithNotification
AttributeError: 'exceptions.KeyError' object has no attribute 'with_traceback'
Desired behavior after PR is merged
The value for attribute after_script_name of transitions updated or created with core's workflow API have a None value
--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.
Description of the issue/feature this PR addresses
This Pull Request fixes an
AttributeError
that arises when triggering transitions that were created or updated by usingsenaite.core.api.workflow
because the transition propertyscript_after_name
(Script (after)) was wrongly set to'None'
:The value of
script_after_name
forTransition
instances is initialized asNone
by default, although the rest of attributes (exceptguard
) are initialized with empty string''
: https://github.com/zopefoundation/Products.DCWorkflow/blob/master/src/Products/DCWorkflow/Transitions.py#L45-L56However, on
setProperties
, the system stringifies the values and therefore, the value of the attribute becomes'None'
instead:This Pull Request makes
senaite.core.api.workflow
to be aware of this inconsistent behavior when updating/creating transitions.Current behavior before PR
The value for attribute
after_script_name
of transitions updated or created with core's workflow API have a'None'
value (as string)Desired behavior after PR is merged
The value for attribute
after_script_name
of transitions updated or created with core's workflow API have aNone
value-- I confirm I have tested this PR thoroughly and coded it according to PEP8 and Plone's Python styleguide standards.