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

Florent Guillaume fg@nuxeo.com
Tue, 11 Mar 2003 18:48:34 +0100


In article <7CDD7B94357FD5119E800002A537C46E2306C9@s5-ccr-r1.ccrs.nrcan.gc.ca> you write:
> 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')

This should BTW read:

  try:
    parent.invokeFactory(obj.getPortalTypeName(),id) # important
  except:
    print 'Could not create '+str(parent.getPhysicalPath()+( str(id), ))
  else:
    newobj = getattr(context, id) # simpler
    if ( review_state == 'published' ):
      context.portal_workflow.doActionFor(newobj, 'publish')

> Problem is, I keep being told that the requested workflow definition was not
> found!

If the object is already 'published', I guess there is no 'publish'
action available...

If that's not the problem, make sure to check in what state your object and its
portal_type really is (you can do that from the Workflow tab in the ZMI).

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com