Am Mon, 2002-09-23 um 00.18 schrieb Lennart Regebro:
> From: "Andreas Kostyrka" <[EMAIL PROTECTED]>
> > 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
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.
> I think you need to answer a couple of questions:
> 1. What is it you want to do?
> 2. How are you trying to do it?
> 3. What is happening when you try to do it?
It's actually trivial ;)
I want to acquire some things in __getattr__.
Basically I want to insert an additional access step like this:
1.) a.b.c.o -> o if o exists in c
2.) a.b.c.o -> Folder.o (where Folder is acquired from a.b.c) if it's
3.) a.b.c.o -> tries to acquire o from a.b.c.
Basically I want "Transparent Folders" which get their "transparent
values from the Acquisition path.
Well, I just had an idea for an implementation:
Third idea: I return some callable object the was generated specifically
for the access from the __getattr__. This is than executed with
Acquisition enabled, so it can try to get the real one, ....
Problem: What if the attribute does not exist? I do not thing that Zope
reacts to well when instead of a AttributeError exception it gets some
object that raises AttributeError when accessed, ....
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -