[Zope-CMF] Point of publication

Kevin Carlson khcarlso@bellsouth.net
Tue, 23 Apr 2002 14:51:54 -0400


Another interesting item is that I noticed the DCWorkflow specifies the
script content_status_modify (located in portal_skins/content) to be called
when posting a change in object state.  That script always returns to the
original object (code below).  Do I need to alter this script to make the
ObjectMoved exception return a value?  Seems that I would have to, but I'm
unsure as how to go about it.

## Script (Python) "content_status_modify"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=workflow_action, comment=''
##title=Modify the status of a content object
##
context.portal_workflow.doActionFor(
    context,
    workflow_action,
    comment=comment)

if workflow_action == 'reject':
    redirect_url = context.portal_url() + '/search?review_state=pending'
else:
    redirect_url = '%s/view?%s' % ( context.absolute_url()
                                  , 'portal_status_message=Status+changed.'
                                  )

context.REQUEST[ 'RESPONSE' ].redirect( redirect_url )



Thanks,

Kevin

-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Kevin Carlson
Sent: Tuesday, April 23, 2002 1:03 PM
To: Dieter Maurer
Cc: zope-cmf@zope.org
Subject: RE: [Zope-CMF] Point of publication


More info:

It appears that DCWorkflow calls "doActionFor" which in turn calls
"_changeStateOf" (both in DCWorkflow.py).  The interesting thing is that the
code for _changeStateOf catches the ObjectMoved exception but doesn't pass
the return value along to doActionFor.  In other words, I think my return
value is getting completely lost.  Could this be a bug?

I am using Zope 2.5.0 with CMF 1.2 and DCWorkflow 0.4.2

Kevin


-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Dieter Maurer
Sent: Monday, April 22, 2002 2:39 PM
To: Kevin Carlson
Cc: zope-cmf@zope.org
Subject: RE: [Zope-CMF] Point of publication


Kevin Carlson writes:
 > Still getting errors when trying to move objects with a script...
 > ...
 > def moveToRep(stateChange) :
 > 	obj = stateChange.object
 > 	p=stateChange.getPortal()
 > 	dest = p.A
 > 	p=obj.aq_inner.aq_parent
 > 	p._delObject(obj.getId())
 > 	n = dest._setObject(obj.getId(), obj)
 > 	raise stateChange.ObjectMoved(n, _redirect(n, "Moved"))
 > ...
 > I am getting the following error:
 >
 > 	Error Type: NameError
 > 	Error Value: global name '_redirect' is not defined
A crystal clear error message:

  The "_redirect" above is undefined, because you did not define
  it. In my script, it is defined as

		from urllib import quote_plus

		def _redirect(obj,msg=None):
		  r= obj.REQUEST.RESPONSE
		  url= '%s/view' % obj.absolute_url()
		  if msg: url+= '?FeedbackSuccessMessage=%s' % quote_plus(msg)
		  r.redirect(url)

  It redirects to the "view" of the moved object. Not sure, that you
  want this redirect...


There is another small problem in your script:

      "_setObject" does not return the object but its id.

Therefore, you need:

      ...
      id= dest._setObject(...)
      n= dest._getOb(id)
      ....

This remedies the problem you reported in your second mail.


Dieter


_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests



_______________________________________________
Zope-CMF maillist  -  Zope-CMF@zope.org
http://lists.zope.org/mailman/listinfo/zope-cmf

See http://www.zope.org/Products/PTK/Tracker for bug reports and feature
requests