[Zope-dev] __getattr__ and Acquisition

Andreas Kostyrka andreas@kostyrka.priv.at
23 Sep 2002 19:59:23 +0200


Am Mon, 2002-09-23 um 18.29 schrieb Florent Guillaume:
> 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.
So how do I call it?
return myitem.__of__(self)
Doesn't make sense, as self is not wrapped and as such DOES not contain
any knowledge how it was accessed, ...
/site1/shared/a/b/c/x
/site2/shared/a/b/c/x
might be quite different things?

My problem especially is not generating a wrapper, but to acquire some
object from up my acquisition chain, ...

> 
> > 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.
But exactly THIS I want to support. How should I know if the object will
not be used sometime in the future with different contexts. How can I
know that my content objects will not be recycled in a second Virtual
Host? etc.

Andreas