[Zope] manage_pasteObjects in manage_afterAdd raises
AttributeError for getPhysicalRoot
Grégoire Weber
gregoire.weber@switzerland.org
Tue, 24 Sep 2002 19:49:21 +0200
Hi Andy,
thats right (its intended to call paste on the index_html object).
index_html is folderish also. For now it is not important, that
this its id is index_html. Correctly said I hope it is not relevant.
By hand I can paste the object into index_html (paste knob in plone).
thanks for your answer anyway.
Greg
At 10:15 24.09.2002 -0700, Andy McKay wrote:
>> index_obj.addToCollection(container._getOb(self.getId()))
>
>> self.manage_pasteObjects(context.manage_copyObjects(id)) # raises ERROR
>below
>
>Looks like you are calling manage_pasteObjects on self, which is the
>index_html object, rather than on the container. You should really be doing
>container.addToCollection(..).
>--
> Andy McKay
> www.agmweb.ca
>
>----- Original Message -----
>From: "Grégoire Weber" <gregoire.weber@switzerland.org>
>To: <zope@zope.org>
>Sent: Tuesday, September 24, 2002 8:07 AM
>Subject: [Zope] manage_pasteObjects in manage_afterAdd raises=
AttributeError
>for getPhysicalRoot
>
>
>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(container.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.p=
y
>, 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.p=
y
>, 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.p=
y
>, 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
>
>
>_______________________________________________
>Zope maillist - Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>** No cross posts or HTML encoding! **
>(Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
_____________________________________
Grégoire Weber
Rigistr. 31
CH-8006 Zürich
Switzerland
phone: +41-(0)1-361 66 11
mobile: +41-(0)79-44 11 457
mailto:gregoire.weber@switzerland.org