[Zope-CMF] programmatically change workflow state

Tres Seaver tseaver@zope.com
Mon, 27 Aug 2001 11:53:21 -0400 (EDT)


On Mon, 27 Aug 2001, Gitte Wange wrote:

> At 07:33 27-08-2001 -0400, you wrote:
> >Gitte Wange wrote:
> >
> >> On Wednesday 15 August 2001 13:25, Florent Guillaume wrote:
> >> 
> >>>>Does this look correct ? It's a bit DCWorkflow-centric unfortunately,
> >>>>because WorkflowTool doesn't expose any method to force a state change.
> >>>>
> >>>Oops, I just found WorkflowTool.setStatusOf ... I guess it answers this
> >>>part of the question :-)
> >
> >> 
> >> I just tried this because I am attaching a memer picture for each
> member. And 
> >> it want it to have status=pending when it has been added (so the members 
> >> don't have to find the picture object themselves and submit it).
> >> 
> >> But there are no pending reviews afterwards and when I try to view the 
> >> picture object I get an error. 
> >> 
> >> So .. any good hints??
> >> 
> >> All I have done was to change the security of the method setStatusOf in
> the 
> >> WorkflowTool module (from private to public) and then call it.
> >> Something I have missed ?
> >
> >
> >'setStatusOf' was private because it was intended to be called
> >only by other "machinery";  you likely want 'doActionFor', passing
> >the "transition name", as 'setStatusOf' is supposed to pass more
> >data than you are probably using.
> >
> 
> Okay ... looking at the WorkflowTool.doActionFor method I see you can pass
> a lot to that function.
> So let me see if I get this:
> the ob argument is the object I want to do something with.
> the action argument would - in this case - be 'setStatusOf'

'action' should be 'publish' ('doActionFor' ends up calling
'setStatusOf' anyway).

> the wf_if is 'default_workflow'

You can leave this off.

> I can leave out the **args and the **kw arguments ??

Yes.

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com