| |
Move object in DCWorkflow
Submitted by: runyaga
Last Edited: 2005-01-16
Category: CMF
|
| Average rating is:
4.75 out of 5
|
(4 ratings) |
|
Description:
One of the most common things done using Workflow in CMF is moving objects around on some transition. Here is a simple recipe that will move only News Item objects to a folder.
|
Source (Text):
o=getattr(state_change, 'object')
obj_parent=o.aq_parent
portal_root=context.portal_url.getPortalObject()
if o.getTypeInfo().getId()=='News Item':
portal_root.Members.manage_pasteObjects( obj_parent.manage_cutObjects(o.getId()) )
from Products.CMFCore.utils import getToolByName
from AccessControl import getSecurityManager
def move_pending(self, state_change):
obj=state_change.object
parent=state_change.object.getParentNode()
dest=self.portal_url.getPortalObject().Members.runyaga
membershiptool=getToolByName(self, 'portal_membership')
member=getSecurityManager().getUser().getUserName()
membershiptool.setLocalRoles(dest, (member,), 'Owner', reindex=0)
dest.manage_pasteObjects( parent.manage_copyObjects( obj.getId() ))
membershiptool.deleteLocalRoles(dest, (member,), reindex=0)
|
Explanation:
check out http://www.zope.org/Members/hathawsh/DCWorkflow_docs
for more information on DCWorkflow also the Expressions.stx file
in the DCWorkflow Product.
after you have completed this recipe. you will be on your way
to Workflow nirvana. you will notice some things such as
inside a Script(Python) some excpetions are swallowed as to not
interfere with the user experience. you will get a feel for these
after some trial and error.
- You will want to understand that states are permissions set for an object.
- Transitions allow for you to hook before/after the tranistion occurs (permissions are applied)
- Worklists are how people will see the objects in the workflow
- Variables are ways to see into Workflow.
Hats off to Zope Corp. for releasing this product. It certainly
makes CMF a excellent product for 99% of the workflow situations
you will encounter. You may also want to search for OpenFlow, an
activity based engine. It is not yet wired into the CMF.
|
Comments:
| Use one script for many types of objects. by rroeber - 2004-10-14 |
## a little twist to this great script will
## allow you to map a 'News Item' to the folder 'newsitems',
## an 'Image' to the folder 'graphics', and so on.
o=getattr(state_change, 'object')
obj_parent=o.aq_parent
portal_root=context.portal_url.getPortalObject()
content_type = o.getTypeInfo().getId()
mappings = {'News Item' : 'newsitems'
,'Image' : 'graphics'
. . .
,}
if content_type in mappings.keys():
portal_root[mappings[content_type]].manage_pasteObjects( obj_parent.manage_cutObjects(o.getId()) )
|
|
| |
| Can't move news item with Plone 1.0a2 by dhart - 2004-10-14 |
Using Zope 2.5.1, CMF 1.3, Plone 1.0a2
Publishing news items results in error:
The object News_Item.2002-08-07.4925 does not support this operation |
|
|
| |
| Re: Use one script for many types of objects. by bobvin - 2004-10-14 |
I used your idea but ran into a problem because the default action after a change in status is to view the object (at the old location), which results in an object-not-found error.
To fix this, I went into portal_properties/navigation and changed default.content_status_modify.success from "action:view" to "url:../folder_contents"
Now when I publish an item, it dumps me into a view of the folder where it came from.
It would be nice if it would go to a view of the newly-moved object, but I haven't been able to get necessary redirects working. |
|
| |
| Fixing Plone's response (was Re: Re: Use one script for many types of objects.) by sh23 - 2004-10-14 |
I wanted to only be placed in the directory when the object was no
longer there. In /Plone/portal_properties/navigation_properties
instead of modifying default.content_status_modify.success, I created
a new entry:
default.content_status_modify.gone url:../folder_contents
I then modified (a custom copy of)
portal_skins/plone_scripts/form_scripts/content_status_modify by
replacing 'success' with status_string in the return statement, and
then adding the following immediately before the return statement:
if context.restrictedTraverse(context.getPhysicalPath(), default=None) == None:
status_string = 'gone'
else:
status_string = 'success'
This is known to work with CMF 1.4 and Plone 1.1 24 June development version. |
|
|
|
| Zclass + Catalog problems by georgeh - 2004-10-14 |
portal_catalog doesn't seem to re-index my zclass content types after
they move. The catalog lists them in their old position, so they
definately work with the catalog, just not after they get published and
moved. |
|
| Openflow by vegalien - 2004-10-14 |
Activity based workflow, is wired to plone through ReFlow
http://www.reflab.it/community/Openprojects/CMFOpenflow/Reflow.docs/how-to-start-with-reflow/view
great how-to to help understand the mechanism of the DCWorkflow !!! |
|
| I try to save published objects into html. by eugene - 2004-10-14 |
I need to save published objects into html.
I add external script that gets objects via http and put them into folder. Also I modified transition "publish" - add script (after).
I found that script is invoked, but at that time when it is invoked, object is still in previous state, so script cannot work with it.
What can I do to run script just _after_ the transition is finished?
I need worklists to be updated before my script start. |
|
| using manage_addLocalRoles by constantin - 2005-01-16 |
Hi,
I could not get the script to work with memebrship.addLocalRoles(..) In that case I still get
the insuficient privilidges page.
It does seem to work with destfolder.manage_addLocalRoles( member, ('Owner', )),
however. |
|
|
|