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

Jean-Francois.Doyon@CCRS.NRCan.gc.ca Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Mon, 10 Mar 2003 18:15:09 -0500


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 =3D context.restrictedTraverse(parent.getPhysicalPath()+( str(=
id),
))
    if ( review_state =3D=3D 'published' ):
context.portal_workflow.doActionFor(newobj, 'publish')

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

I am attempting to migrate from 2.5.1/CMF1-2 to 2.6.1/CMF1-3 ... and am
using DCWorkflow 0.4.2 with a really trivial workflow (The default). I ju=
st
moved the Data.fs over ...

I noticed folders are now Workflow aware too, so I hit the "Update securi=
ty
settings", and then try to batch publish them with something like:

def publish(o):
  context.portal_workflow.doActionFor(o, 'publish')
  for obj in o.objectValues():
    publish(obj)

for o in container.objectValues():
  if ( o.meta_type =3D=3D 'Portal Folder' ):
    publish(o)

Run from the root of the CMF site ... This one ALSO complains about no
workflow being found!

Anyone know what's going on? I checked my workflow and it's there just th=
e
way it should be, and it DOES define the "publish" action ... I noticed
something about the trigger settings and played with that, but not luck
there either ...

Any help would be much appreciated!

Thanks,
J.F.

-----Original Message-----
From: Raphael Ritz [mailto:ritz@itb.biologie.hu-berlin.de]
Sent: Monday, March 10, 2003 3:27 AM
To: Jean-Francois.Doyon@CCRS.NRCan.gc.ca
Cc: zope-cmf@zope.org
Subject: Re: [Zope-CMF] Inconsistent CMF Objects, ZMI issue, how to
correct/convert objec ts ?




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

>Hello,
>
>I just tried to upgrade my current 2.5.1+CMF-1.2 to 2.6.1+CMF1.3 ...
Without
>success ... For some reason, with some Documents the default view is fou=
nd,
>but not for others.
>
>After doing some digging, I discovered this may be related to the fact t=
hat
>not all CMF objects seem to be equal. Some "Documents" have a document
>looking icon, some don't.
>
>A while ago, someone had mentionned, in one thread or another, that
creating
>CMF objects from the ZMI was bad somehow. I think I am now suffering fro=
m
>being guilty of doing such things when I didn't know any better (Other t=
han
>the wrong Icon, everything seemed to work ok).
>
>When I started with Zope I wrote a batch loader similar to site_loader.p=
y
>... but in Perl, and for the CMF ... Only I modeled it's behavior after
what
>I saw in the ZMI ... I know this was a mistake! But now I'm stuck with
>thousands of "bad" CMF objects it seems.
>
>So, the question now is how do I fix this? Why is the ZMI way of doing
>things wrong, and if it's known to be wrong why is it even there? I'd li=
ke
>to better understand this behavior ...
>
Adding an object via ZMI by default calls the object's constructor direct=
ly
whereas the proper CMF/Plone way is to use 'invokeFactory'
which takes care of all the add-ons the CMF provides (catalog, workflow=20
etc.)
Moreover, calling, e.g., 'invokeFactory('Folder', myfolderid)'  creates=20
a portal_folder
which is different from a stock Zope folder (which doesn't provide=20
'invokeFactory'
for instance).
In any case I would recommend that you recreate your objects. And I=20
wouldn't use
XML import/export but rather more direct ways like FTP or even Pythons=20
urllib for
stuff that you have available somewhere else. Objects that you have in ZO=
DB
already don't need to be exported/changed/imported but you can just get t=
hem
from within Zope, figure out their metatype and all other properties and=20
then create
the appropriate portal object.

HTH,

    Raphael
=20
Raphael

>
>Is there a way for me to fix the objects in place? Possibly by exporting=
 as
>XML, editing the XML, and re-importing? (A technique, believe it or not,
>I've used successfully recently :)
>
>I could also write a script that takes ALL objects, create a new object
>PROPERLY, migrates the properties, and renames ... But I want to make su=
re
I
>use the RIGHT methods and everything this time ...
>
>Any help in dealing with this would be greatly appreciated!
>
>Thanks,
>
>Jean-Fran=E7ois Doyon
>Internet Service Development and Systems Support / Soutien de syst=E8mes=
 et
>developement de services Internet
>GeoAccess Division / Division G=E9oAcc=E8s
>Canada Center for Remote Sensing / Centre canadien de t=E9l=E9d=E9tectio=
n
>Natural Resources Canada /  Ressources naturelles Canada
>Phone / T=E9l=E9phone: (613) 992-4902
>Fax / T=E9l=E9copieur: (613) 947-2410
>http://atlas.gc.ca
>
>
>_______________________________________________
>Zope-CMF maillist  -  Zope-CMF@zope.org
>http://mail.zope.org/mailman/listinfo/zope-cmf
>
>See http://collector.zope.org/CMF for bug reports and feature requests
>
> =20
>