[Zope-CMF] Moving Items with Workflow
Ryan P. de Vega
rpd4972@hbu.edu
Wed, 28 Aug 2002 15:35:47 -0500
Ronald,
Unfortunately, I have not dealt with this particular problem. My task was
simply to create a copy of the member folders and contents to another
portal folder which I created. This way when our web sites reference web
content (located in the new portal folder), all portal objects being
submitted for approval are unviewable to the outside world until they are
published (which is the action which triggers my copy to new location
script). I will be referencing the content in my home-made folder just as
I would with any other page templates or dtml in zope - but not in the cmf
realm. This is my manual way of creating a versioning system, apparently
this is the best way right now.
I can only think of two problems that may be causing your issue. 1) You
are copying your objects into a regular zope folder and not a portal
folder (select cmf core content when adding new folder instead of folder).
This I find unlikely because I am not even sure if you can copy portal
content into a non-portal folder. 2) You need to reference your copied
objects into the cmf data dictionary. This is something that I know
nothing about, except that there is some sort of object catalog managed by
the cmf where attributes of objects are stored. ie. this is from
MembershipTool.py:
# Overcome an apparent catalog bug.
f.index_html.reindexObject()
wftool = getToolByName( f, 'portal_workflow' )
wftool.notifyCreated( f.index_html )
Here is the code that I have come up with to complete the task I spoke of
above. When the script is run I can see the copied content in the new
location through the portal - which is what you said you were having
trouble with. It is not completely working, but it is almost there. As
you will see I can get the folder to be created at the new location, the
objects will copy over into the relevant folder, the script will test for
the existence of the parent folder at hand, and if the folder is not there
it will be created. The problem is that I can't get the test to work
which tests for the existence of the copied object. If this test isn't
working a new copy of the object will be made each time the script is run.
That is why I need to delete the old object and add the new one, but if
the object is not there the delete part needs to be skipped. Any ideas on
how to properly test for the existence of the object?
I hope this stuff helps. Good luck.
Sincerely,
Ryan de Vega
Programmer, Database Support
Houston Baptist University
281-649-3449
______________________________________________________________________________________________
o=getattr(state_change, 'object')
obj_parent=o.aq_parent
portal_root=context.portal_url.getPortalObject()
content_type = o.getTypeInfo().getId()
mappings = {'Discussion Item' : 'pages'
,'Document' : 'pages'
,'Favorite' : 'pages'
,'File' : 'pages'
,'Folder' : 'pages'
,'Image' : 'pages'
,'Link' : 'pages'
,'News Item' : 'pages'
,'Topic' : 'pages'
,}
if content_type in mappings.keys():
id = obj_parent.getId()
title = obj_parent.title_or_id()
location = portal_root[mappings[content_type]]
if not hasattr(location, id):
location.manage_addPortalFolder( id, title)
obj2=getattr(location, id)
"""if hasattr(location, id):
location.manage_delObjects(o.getId())"""
obj2.manage_pasteObjects(obj_parent.manage_copyObjects(o.getId()))
________________________________________________________________________________________
rroeber1@unl.edu writes:
>Ryan,
>
>A few days ago you commented on a recipe I submitted to Zope Labs. Thank
>you for your kind works.
>
>I do have a problem with my script in that once the Item is moved and I
>return from the script (Workflow), CMF cannot find my object anymore,
>since it has moved. I've played a bit with ObjectMoved, but with mixed
>results.
>
>Have you had to solve this problem? And if so how.
>
>Thank you.
>
>--------------------------------------------------------------------
>Ronald L. Roeber
>CIT-IANR
>University of Nebraska
>Lincoln, NE 68583 Phone: (402) 472-5630
>email: rroeber1@unl.edu