[Zope] overload __getattr__ in brains-class?

Jo Meder jo@meder.de
Sun, 21 Jul 2002 01:52:55 +0200


Am 19.07.2002, 21:14 Uhr
	schrub Dieter Maurer <dieter@handshake.de>:

 
>   "__getattr__" is only called when the normal lookup fails.
>   This includes the lookup in "self.__dict__", any subclass
>   and (in Zope) the acquisition context.

Ah yes, you're right of course. Sometimes it pays to revisit the 
documentation :-O.

> It is implemented in "C" as an ExtensionClass without "__dict__".
> Therefore, you cannot assign any (new) attributes to its instances:
> the set of attributes is fixed to the set of result columns.
> All derived classes inherit this property (they do not have a
> "__dict__").

I see, that explains the behaviour I observed very well.

> I think, it is a bug. I reported it in the mailing list and
> in the (old) collector.

At least it is very inconvenient in my current situation. Do you have an
url where I can look up your bug report and follow further development?

> It could probably easily be changed (whether or not an Extension Class
> has a __dict__ or not is controlled by a flag in the corresponding
> type).

You mean I just have to change "EXTENSIONCLASS_NOINSTDICT_FLAG" to
"EXTENSIONCLASS_INSTDICT_FLAG", recompile and I'm set? It can't be that
simple, can it?

> But it's implemented in "C" and in order to use the modification,
> one needs a "C" development systems. Many Zope users do not have
> one. That's why I more hesitant to provide patches for "C" parts
> than for Python parts.

I'm hesitating to deploy my own patches to C code as well. But with you
confirming that this is a problem with the Record-class and not my own
inability to produce correct code I'm more than happy to apply this
patch.

So now I have a semi-solution where I can insert my own attributes into
__dict__ but my own __getattr__ and __setattr__ won't get called, no
matter what I do. And I had no success in trying to install these
methods after the __init__ finished.

But thanks anyway for the insights.

	Jo.


-- 
Internetmanufaktur Jo Meder ---------------------- Berlin, Germany
http://www.meder.de/ ------------------- fon: ++49-30-417 17 63 33
Kollwitzstr. 75 ------------------------ fax: ++49-30-417 17 63 45
10435 Berlin --------------------------- mob: ++49-170- 2 98 89 97
Public GnuPG-Key ---------- http://www.meder.de/keys/jo-pubkey.txt