[Zope-CMF] Point of publication

Kevin Carlson khcarlso@bellsouth.net
Tue, 23 Apr 2002 12:47:04 -0400

You're right about the error message being crystal clear...:-)

I have added in the code you sent and still, believe it or not, cannot get
this thing to work.  The object moves just fine but the remaining problem is
two-fold.  First, the system seems to disregard the redirect and point me
back at the view action for the original object.  I get a resource not found
error with the resource being the original object (in the member folder).
Second, when I get this error message I appear to have been logged off the
system (the left nav shows guest instead of the member name).  Odd...

Here is the script I am using.  It is run as the "after" script on the
Submit transition in the default workflow (DCWorkflow).

def moveToRep(stateChange) :
	obj = stateChange.object
	dest = portal.A
	newid = dest._setObject(obj.getId(), obj)
	newobj = dest._getOb(newid)
	raise stateChange.ObjectMoved(newobj, _redirect(newobj, "Moved"))

from urllib import quote_plus

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



-----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):
		  url= '%s/view' % obj.absolute_url()
		  if msg: url+= '?FeedbackSuccessMessage=%s' % quote_plus(msg)

  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.


Zope-CMF maillist  -  Zope-CMF@zope.org

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