[Zope-dev] How to override __getattr__ and not break acquisition

Nicholas Henke henken@seas.upenn.edu
Wed, 5 Jun 2002 09:25:42 -0400


How about making __setattr__ work ? I keep having Acquisition tell me tha=
t it=20
cannot find the Acquisition.Acquired properties.

Nic

On Wednesday 05 June 2002 09:21 am, Casey Duncan wrote:
> If your __getattr__ fails to find what it wants, it should raise an
> AttributeError. This will give the ball back to the acquisition
> machinery.
>=20
> Thusly:
>=20
> def __getattr__(self, name):
>     if name =3D 'foo':
>         return self.foo()
>     raise AttributeError, name
>=20
> hth,
>=20
> -Casey
>=20
> On Tue, 2002-06-04 at 22:28, Erik A. Dahl wrote:
> > Ok I need to override __getattr__ in one of my product classes.  I'm=20
> > sure this is killing acquisition but not sure about the persistence=20
> > stuff (I think this is working).  Is there a way to make this work?=20
> >  Here is what I'm doing:
> >=20
> > def __getattr__(self, name):
> >     if name =3D=3D 'myattr':
> >         return self.myattr()
> >=20
> >=20
> > I assume that somewhere in the Acquisition code there is a __getattr_=
_=20
> > but I can't find it.  I tried calling Implicit.__getattr__ but its no=
t=20
> > there.  If some one has an example that would be great.
> >=20
> > -EAD
> >=20

>=20