[Zope] manage_pasteObjects in manage_afterAdd raises AttributeError
for getPhysicalRoot
Grégoire Weber
gregoire.weber@switzerland.org
Tue, 24 Sep 2002 17:07:02 +0200
Hi,
below an issue I don't have any idea where the problem lies. Are there some
experts around that could give me some advice? Thanks! The code is for the
redesign of the swiss community site http://www.zope.ch hopefully working
in two weeks. So please, help!
Are there any known issues copy&pasting a freshly added object A to another
folderish object I in the A's manage_afterAdd hook?
Doing Copy&Paste by hand (by GUI) after the object A was added works.
Have a look at the simplified code snippet (Python Product):
def manage_afterAdd(self, item, container):
""" simplified code called after instanation of object A
(self) in folder P (container)
"""
index_obj = getattr(container.aq_base, 'index_html', None)
if (index_obj is not None) and (index_obj.meta_type == self.meta_type):
# P has an object I (index_obj) of the same type as A is
index_obj.addToCollection(container._getOb(self.getId()))
def addToCollection(self, obj):
""" simplified code in the same class called on index_html object
"""
container = obj.getParentNode()
id = obj.getId()
# this copies object A (obj, just instanated before manage_afterAdd!!!)
# to object I (self, same as index_obj above)
self.manage_pasteObjects(context.manage_copyObjects(id)) # raises ERROR below
Greg
-------------------------------------------------------------------------
Error Type: AttributeError
Error Value: getPhysicalRoot
Traceback (innermost last):
File D:\prog\ZOPE_T~1\lib\python\ZPublisher\Publish.py, line 150, in publish_module
File D:\prog\ZOPE_T~1\lib\python\ZPublisher\Publish.py, line 114, in publish
File D:\prog\ZOPE_T~1\lib\python\Zope\__init__.py, line 159, in zpublisher_exception_hook
(Object: gregweb)
File D:\prog\ZOPE_T~1\lib\python\ZPublisher\Publish.py, line 98, in publish
File D:\prog\ZOPE_T~1\lib\python\ZPublisher\mapply.py, line 88, in mapply
(Object: createObject)
File D:\prog\ZOPE_T~1\lib\python\ZPublisher\Publish.py, line 39, in call_object
(Object: createObject)
File E:\user\greg\data\zope_test\Products\CMFCore\FSPythonScript.py, line 90, in __call__
(Object: createObject)
File D:\prog\ZOPE_T~1\lib\python\Shared\DC\Scripts\Bindings.py, line 252, in __call__
(Object: createObject)
File D:\prog\ZOPE_T~1\lib\python\Shared\DC\Scripts\Bindings.py, line 283, in _bindAndExec
(Object: createObject)
File E:\user\greg\data\zope_test\Products\CMFCore\FSPythonScript.py, line 124, in _exec
(Object: createObject)
(Info: ({'script': <FSPythonScript instance at 018E4DD0>, 'context': <PloneFolder instance at 0227A820>, 'container': <CMFSite instance at 0227D278>, 'traverse_subpath': []}, (None, 'Manual Collection'), {}, (None, None)))
File Script (Python), line 12, in createObject
File E:\user\greg\data\zope_test\Products\CMFCore\PortalFolder.py, line 362, in invokeFactory
(Object: gregweb)
File E:\user\greg\data\zope_test\Products\CMFCore\TypesTool.py, line 824, in constructContent
(Object: portal_types)
File E:\user\greg\data\zope_test\Products\CMFCore\TypesTool.py, line 513, in constructInstance
(Object: Manual Collection)
File E:\user\greg\data\zope_test\Products\CMFManualCollection\ManualCollection.py, line 84, in addManualCollection ##### this is the factory !!!
File D:\prog\ZOPE_T~1\lib\python\OFS\ObjectManager.py, line 267, in _setObject
(Object: gregweb) ##### parent object P (Folder)
File E:\user\greg\data\zope_test\Products\CMFManualCollection\ManualCollection.py, line 270, in manage_afterAdd
(Object: Manual_Collection.2002-09-24.1731) ##### object A to be copied (folderish)
File E:\user\greg\data\zope_test\Products\CMFManualCollection\ManualCollection.py, line 675, in addToCollection
(Object: index_html) ##### target object index_html (the target, also folderish)
File D:\prog\zope_test\lib\python\OFS\CopySupport.py, line 144, in manage_pasteObjects
(Object: index_html)
AttributeError: (see above)
_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org