[Zope-CMF] Point of publication

Kevin Carlson khcarlso@bellsouth.net
Sun, 21 Apr 2002 21:42:09 -0400


Still getting errors when trying to move objects with a script...

I tried adding the code below to an external method (placed in the
/Zope/Extensions directory) that is called on the "submit" transition from a
DCWorkflow.

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"))


[where "p.A" is the folder "A" in the root of the CMF instance]

I am getting the following error:

	Error Type: NameError
	Error Value: global name '_redirect' is not defined


The traceback is as follows:

Traceback (innermost last):
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\Publish.py, line 150, in
publish_module
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\Publish.py, line 114, in
publish
  File C:\PROGRA~1\ZopeTest\lib\python\Zope\__init__.py, line 158, in
zpublisher_exception_hook
    (Object: Test)
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\Publish.py, line 98, in
publish
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\mapply.py, line 83, in
mapply
    (Object: content_status_modify)
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\Publish.py, line 44, in
missing_name
  File C:\PROGRA~1\ZopeTest\lib\python\ZPublisher\HTTPResponse.py, line 492,
in badRequestError
BadRequest: (see above)



I must not be importing something -- any ideas?  Also, what object type is
the "stateChange" object that is passed into the workflow script?

Thanks,

Kevin

-----Original Message-----
From: Dieter Maurer [mailto:dieter@handshake.de]
Sent: Thursday, April 18, 2002 3:46 PM
To: Kevin Carlson
Cc: zope-cmf@zope.org
Subject: RE: [Zope-CMF] Point of publication


Kevin Carlson writes:
 > Reviving an old thread...
 >
 > I have been able to modify the DefaultWorkflow.py source to accomplish
 > moving an object to a different folder on publication.  Now that I am
 > finally getting around to attempting to do this with a script, I am
having
 > some trouble.  Any sample source available?
I use the following External Method to move an object to a "DataCenter".

def releaseNew(stateChange):
  obj= stateChange.object
  p= stateChange.getPortal()
  Center= getCenter(p,obj); t= getType(obj)
  # remove the object from its original place - this should uncatalog
  p= obj.aq_inner.aq_parent
  p._delObject(obj.id)
  # now install
  n= Center.addObject(obj)
  # finally, tell the workflow that we moved the object
  raise stateChange.ObjectMoved(n,_redirect(n,t + ' freigegeben und ins
DataCenter übertragen'))

The DataCenter has a special method "addObject" that adds an object,
giving it a new automatically generated id.
You can use the "ObjectManager._setObject" method, when the
destination is a standard "ObjectManager".



Dieter