[Zope-dev] __getattr__ and Acquisition
Florent Guillaume
fg@nuxeo.com
Mon, 23 Sep 2002 09:12:30 +0000 (UTC)
Andreas Kostyrka <andreas@kostyrka.priv.at> wrote:
> Am Mon, 2002-09-23 um 00.18 schrieb Lennart Regebro:
> > From: "Andreas Kostyrka" <andreas@kostyrka.priv.at>
> > > I've just discovered, that Acquisition does not work with __getattr__,
> > > right?
> >
> > That depends on what you mean with "does not work". :-)
> >
> > > (I assume that this is so because something like getattr(mybase,attr) is
> > > called during the acquisition process to prevent infinite recursion.)
> > >
> > > Anyway to get around that? (To basically get a wrapped self from
> > > somewhere?)
> >
> > That's what self usually is... :-)
> Nope it is not. In a normal method you can access something acquired
> like this:
> self.acquired_value.
> Even more, this works for __bobo_traverse__. It just works for the
> publishing not accessing my attributes later on during publication.
>
> The problem is, that __getattr__ does not have access to the acquisition
> chain. Now I storing the "acquisition chain" in the object is not a
> sound proposition, because it is not thread safe. Worse the object might
> be accessed in some way that makes the acquisition chain not be updated.
Anoter way to do that is to play games with __of__.
Look at the implementation of the skins tool in CMF for an example.
Florent
--
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com