[Zope-CMF] Workflow not found, problem with doActionFor()

Jean-Francois.Doyon@CCRS.NRCan.gc.ca Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Wed, 12 Mar 2003 15:10:14 -0500


Hello,

Thanks for the help ...

It's not a typo, you're just missing the rest of the script :) what I'm
doing is converting objects created with manage_addContent (Or whatever that
method is that the ZMI uses), with properly created ones using invokeFactory
... the review_state testing actually refers to the review state of the
"original" object ...

Although I don't test for it programmatically, the default state for my CMF
created objects is "private", and if I go through the site and look at the
actions box, that's what they are set to, as expected. So now I need to set
the "new" objects to the same state as it's ancestor (The only other state
in my current workflow is "published"). And this is where I run into the
trouble I mentionned.

It just won't work I get:

WorkflowException: No workflow provides the "publish" action.

Which is essentially NOT true, since there definitely is one (I can even do
the publish through the actions box without problem, just not through code).

One thing I noticed while working on this script is that there seems to be
some sort of transactional/commit behavior in Zope that I'm not aware of ?

I first ran into this when I was trying to rename a recently create object
(I was creating the object with a temporary id, then renaming ...) ... The
renaming wouldn't work, I kept being told the object didn't exist! (Even
though it was very much there). I ended up going about it the opposite way,
I rename the original object FIRST, then create the new one with it's final
id right away, avoiding the need to rename the NEW one.

But now that I'm running into this, I can't help but see similarities in the
behavior of the error.  If there some sort of "commit" that happens
internally that maybe hasn't happened yet by the time I try to change the
review state? This would explain why I can't do it in the code, but I CAN do
it after the fact ... much like with the renaming ...

Any ideas, suggestions, comments ?

Thanks again,
J.F.


-----Original Message-----
From: Raphael Ritz [mailto:ritz@itb.biologie.hu-berlin.de]
Sent: Tuesday, March 11, 2003 3:17 AM
To: Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] Workflow not found, problem with doActionFor()




Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:

>I am now running into a problem using doActionFor in order to publish
>programmatically created objects.
>
>The interesting bit of code looks like this:
>
>  # Create the empty new object using the proper method invokeFactory
>  try:
>    parent.invokeFactory(obj.Type(),id)
>  except:
>    print 'Could not create '+str(parent.getPhysicalPath()+( str(id), ))
>  else:
>    newobj = context.restrictedTraverse(parent.getPhysicalPath()+( str(id),
>))
>    if ( review_state == 'published' ):
>context.portal_workflow.doActionFor(newobj, 'publish')
>
>Problem is, I keep being told that the requested workflow definition was
not
>found!
>
>  
>
1. Just for clarification: is the workflow or the workflow 
action/transition not found?
2. If it's not a typo in the code above: Trying to publish a published 
item usually doesn't
work because there is no such transition from the published to the 
published state.
So make sure that you test on a state from where the 'publish' 
transition exists.

Raphael

>  
>