[Zope] manage_pasteObjects in manage_afterAdd raises AttributeError for getPhysicalRoot

Grégoire Weber gregoire.weber@switzerland.org
Wed, 25 Sep 2002 02:05:17 +0200


Sorry Dieter and thanks a lot,

it was too late, when I read your e-mail below, so I missed the 
point ('Usually, you should check ...) and had to find it out by 
myself ... grmpf :-(.

Greg

At 22:16 24.09.2002 +0200, you wrote:
>=?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 

_____________________________________
Grégoire Weber
mailto:gregoire.weber@switzerland.org