Create or visit existing workflow definition in ZMI
Visit Transitions tab
Add a transition
Click any of the following top-level ZMI tabs: Worklists, Variables, States, Permissions
What I expect to happen:
I expect the top-level tabs to go to expected destinations (not 404)
What actually happened:
Tab links are relative to the wrong thing
Only reasonable workaround is clicking breadcrumbs to reload your context, and then clicking top-level tabs
impact
this makes it difficult to define workflows TTW (without a great deal of frustration and workaround)
in more detail — what actions are broken:
Top level tabs break after any of the following actions:
States: assign a default state
States: delete a state
Transitions: add a transition
Transitions: delete a transition
Transitions: rename a transition
Worklist: delete a worklist
Worklist: rename a worklist
Variable: delete a variable
Variable: rename a variable
What version of Python and Zope/Addons I am using:
This breaks in Zope 4 (Plone 5.2) and Zope 5 (Plone 6.x)
Unsure: this might have been broken in Zope 2 in older Plone 5, and for a good long while we've been dealing with this.
What is failing here:
links in DTML to top-level tabs inside a workflow definition are relative
The classes implementing management views for DCWorkflow return instead of redirect after actions that mutate saved-state for the definition's states, transitions, worklists, or
Ideally, the manage_main for States, Transitions, Worklists, and Variables classes would be smart enough to redirect back to manage_main instead of returning it with a different URL context.
Likewise, manage_permissions should also redirect.
Workaround (which has limited testing) is a monkey patch:
def workflow_zmi_manage_main_wrapper(self, REQUEST, manage_tabs_message=None):
view = REQUEST.steps[-1]
target = 'manage_main'
if view != target:
query = '?manage_tabs_message={}'.format(manage_tabs_message or '')
REQUEST.response.redirect(
'./{}/{}{}'.format(
self.__class__.__name__.lower(), # States -> states in url
target,
query if manage_tabs_message else '',
)
)
return
return self._old_manage_main(REQUEST, manage_tabs_message)
def workflow_zmi_manage_permissions_wrapper(
self,
REQUEST,
manage_tabs_message=None
):
if REQUEST.steps[-1] != 'manage_permissions':
query = '?manage_tabs_message={}'.format(manage_tabs_message or '')
REQUEST.response.redirect(
'{}/manage_permissions{}'.format(
self.absolute_url(),
query if manage_tabs_message else '',
)
)
return
return self._old_manage_permissions(REQUEST, manage_tabs_message)
Which can be applied in ZCML via collective.monkepatcher like:
<!-- more elided, but you need to patch States, Transitions, Variables, Worklists with first function above -->
<monkey:patch
description="patch DCWorkflow ZMI Worklists manage_main to fix tab links"
class="Products.DCWorkflow.Worklists.Worklists"
original="manage_main"
preserveOriginal="true"
replacement=".monkeypatch.workflow_zmi_manage_main_wrapper"
/>
<monkey:patch
description="patch DCWorkflow ZMI manage_permissions to fix tab links"
class="Products.DCWorkflow.WorkflowUIMixin.WorkflowUIMixin"
original="manage_permissions"
preserveOriginal="true"
replacement=".monkeypatch.workflow_zmi_manage_permissions_wrapper"
/>
I am not 100% confident in the correctness or side-effect profile of this patching, though (it works for me, but I'm unclear if there is a better solution than redirecting, e.g. fixing the DTML tab links).
BUG/PROBLEM REPORT
What I did:
Worklists
,Variables
,States
,Permissions
What I expect to happen:
What actually happened:
impact
in more detail — what actions are broken:
Top level tabs break after any of the following actions:
What version of Python and Zope/Addons I am using:
What is failing here:
manage_main
forStates
,Transitions
,Worklists
, andVariables
classes would be smart enough to redirect back tomanage_main
instead of returning it with a different URL context.manage_permissions
should also redirect.Workaround (which has limited testing) is a monkey patch:
Which can be applied in ZCML via
collective.monkepatcher
like:I am not 100% confident in the correctness or side-effect profile of this patching, though (it works for me, but I'm unclear if there is a better solution than redirecting, e.g. fixing the DTML tab links).