[Erp5-dev] Attribute Lookup and ERP5Type.Base

Patrick Gerken do3ccqrv at googlemail.com
Tue Apr 4 14:06:11 CEST 2006


Hello,

today I was hunting a really strange behaviour, in our ERP5 system.
I was trying to retrieve a Category via searchFolder(), and got back a
None object. also a direct access via category.category_to_search_for
returned None. category.__getattr__('category_to_search_for') returned
the correct category.
Diving deep into attribute resolving, it appeared, that somehow my
category_to_search_for has sneaked into the __dict__ attribute of the
Base Class ERP5Type.Base. Therefor the lookup in all base classes of
the class of the category instance finds the item, and __getattr__
gets never called.
Carefully looking into that __dict__, I saw many, maybe twohundred
entries in there. That seems to be the source of the annoying
twohundred results when I try a dir() on an erp5 object.
I deleted the __dict__ entry by hand and everything was fine, but I am
trying to understand, how it got there, and more importantly, what is
going on in ERP5Type.Base. Is this some form of getting faster lookups
for dynamically generated accessors?

Maybe someone here can provide some insight


More information about the Erp5-dev mailing list