[Zope-CMF] Point of publication
Dieter Maurer
dieter@handshake.de
Mon, 22 Apr 2002 20:39:12 +0200
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