[Zope-dev] __getattr__ and Acquisition

Florent Guillaume fg@nuxeo.com
Mon, 23 Sep 2002 16:29:50 +0000 (UTC)


Andreas Kostyrka  <andreas@kostyrka.priv.at> wrote:
> Am Mon, 2002-09-23 um 11.12 schrieb Florent Guillaume:
> > Anoter way to do that is to play games with __of__.
> > Look at the implementation of the skins tool in CMF for an example.
> Doesn't help, as I do NOT know my container :(

Yes it does.
__of__ is non-intuitive but it can work.

> Basically __getattr__ when called does not know it's containment
> anymore. :(

You didn't look a the code I pointed to you. Look at CMFCore/Skinnable
to be precise (not everything is to be used of course).

* In __of__ you store the parent in a volatile attribute,
* in __getattr__ you lookup the volatile attribute

This works as long as your object is not used in several different
acquisition contexts.


Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com