[Zope] manage_pasteObjects in manage_afterAdd raises AttributeError for getPhysicalRoot

Dieter Maurer dieter@handshake.de
Tue, 24 Sep 2002 22:16:10 +0200


=?iso-8859-1?Q?Gr=E9goire?= Weber writes:
 > ...
 > def addToCollection(self, obj):
 > ...
 >    self.manage_pasteObjects(context.manage_copyObjects(id)) # raises ERROR below
 > -------------------------------------------------------------------------
 > Error Type: AttributeError
 > Error Value: getPhysicalRoot
 > 
 > Traceback (innermost last):
 >   File D:\prog\zope_test\lib\python\OFS\CopySupport.py, line 144, in manage_pasteObjects
 >     (Object: index_html)
 > AttributeError: (see above)
This means, "self" above, does not have a method "getPhysicalRoot".

This may be because it is only partially acquisiton wrapped.

   Usually, you should check for attribute existence with "aq_base"
   but access without the "aq_base".

   I.e., you should use the following idiom:

	 if hasattr(aq_base(obj),'some_attribute'):
	   my_attribute= getattr(obj,'some_attribute')
	   ...


Dieter