[Zope-CMF] Point of publication

Kevin Carlson khcarlso@bellsouth.net
Mon, 22 Apr 2002 16:02:12 -0400


If anyone is still interested in following this thread, here are the further
exploits of the great object moving exercise... :-)

I have found that if I remove the "raise stateChange..." line from the
script that the object does move.  The only problem is that the object
instance that was removed remains catalogued.  I'm hoping that once I manage
to successfully raise the ObjectMoved exception that this will solve that.
I will post complete code (with documentation) when I have this worked out.

Thanks to everyone for their help on this to date!

Kevin

-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Kevin Carlson
Sent: Sunday, April 21, 2002 10:41 PM
To: Dieter Maurer; zope-cmf@zope.org
Subject: RE: [Zope-CMF] Point of publication


Even more strangeness...

I replace the last line of the script below with:

	raise stateChange.ObjectMoved(n)

and now I'm receiving a new error:

	Error Type: TypeError
	Error Value: object has read-only attributes

and this traceback:

 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: fdsafdsa)
  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 be missing something simple. I can't believe that it would be so
complex to move an object from one location to another.  Any additional
ideas anyone?

Thanks,

Kevin

-----Original Message-----
From: zope-cmf-admin@zope.org [mailto:zope-cmf-admin@zope.org]On Behalf
Of Kevin Carlson
Sent: Sunday, April 21, 2002 9:42 PM
To: Dieter Maurer; zope-cmf@zope.org
Subject: RE: [Zope-CMF] Point of publication


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



_______________________________________________
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