[Zope-CMF] DCWorkflow changing state
Kari-Hans Kommonen
khk@uiah.fi
Wed, 13 Feb 2002 23:54:49 +0200
Here's a Q&D solution from a novice...
You need a script that changes the state. I figured out how by
looking at how the default workflow was recreated in the example
included with the DCWorkFlow installation, but in any case, here a
simple way to do it.
In the portal skins, in the folder "content", there is a python
script called "content_status_modify":
------copy------
## Script (Python) "content_status_modify"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=workflow_action, comment=''
##title=Modify the status of a content object
##
context.portal_workflow.doActionFor(
context,
workflow_action,
comment=comment)
if workflow_action == 'reject':
redirect_url = context.portal_url() + '/search?review_state=pending'
else:
redirect_url = '%s/view?%s' % ( context.absolute_url()
, 'portal_status_message=Status+changed.'
)
context.REQUEST[ 'RESPONSE' ].redirect( redirect_url )
------copy------
You can customize this for your needs, or simply call this script to
change the status in your workflow. Here's how I did it the latter
way.
Let's assume that the state you want to reach is called "XX":
In the configuration form of the "transition", in the part where you
configure the stuff to "Display in actions box", fill the fields like
this:
Name (formatted): XX
URL (formatted): %(content_url)s/content_status_modify?workflow_action=XX
Category: workflow
This will make the actions box display the text XX, and when the link
is followed, the call to the Python script in the URL will change the
state and redirect back to the page (unless your state was "reject").
hope this helps...
khk
---------
At 16:08 +0100 12.2.2002, javila@neotec.info wrote:
>Hi there,
>
>I have a DCworkflow problem. I have configured the states and the transitions
>for a workflow.
>When the trigger type is Automatic it works perfectly, but the problem comes
>when I select the option "Initiated by user action".
>The problem is that it doesn't change the state of the workflow, it remains in
>the same state even though i specify to go to the next state
>(Destination state
>= another state).
>
>If i select the option "Initiated by user action", when the action (script
>execution) is finished, does the workflow change the state
>automatically? Or it
>has to be done programmatically. If so, could anyone tell me how?