[Zope-dev] __getattr__ and Acquisition

Andreas Kostyrka andreas@kostyrka.priv.at
25 Sep 2002 19:16:50 +0200


Am Mit, 2002-09-25 um 12.44 schrieb Lennart Regebro:
> From: "Andreas Kostyrka" <andreas@kostyrka.priv.at>
> To: "Lennart Regebro" <lennart@torped.se>
> > > You shouldn't, really.
> 
> > Why not?
> 
> Because that's not how it's supposed to work. You can override __getattr__
> to have special magick attributes. Acquisition is not a special magick
> attribute. __getattr__ is only called when an attribute aren't found in a
> "normal" way, and in the context of Zope, Acquicistion would be regarded as
> normal. :-)
But my attributes are not normal. So I should generate them by
__getattr__. Only by noticing that I could get the same effect by
putting my attribute source in front of my object in the acquisition
chain.

The question is still, how does one a __getattr__ that needs (as a
client) acquisition to calculate the attribute.
(Basically __of__ works only if I do not need to know the attribute name
and do not mind a changed acquisition chain, __getattr__ works only if I
do not need Acquisition, ...)

> > Done. Only thing I've noticed that the Catalog shows this "additional"
> > path elements, ...
> 
> I guess that depends on when you patch in the extra object in the
> acquisition. If you do it in __of__() then I guess it's visible all the
Well, where else can I patch it in?

Andreas
-- 
Andreas Kostyrka <andreas@kostyrka.priv.at>