[Zope] overload __getattr__ in brains-class?
Philipp Auersperg
phil@bluedynamics.com
Mon, 22 Jul 2002 04:43:19 +0200
If you look at the brains code in Results.py you see that on the fly a
class called 'r' is created that inherits from
(Record,Implicit,brains,zbrains) where brains is your brain class.
see ./lib/python/Shared/DC/ZRDB/Resuts.py line 67 (Zope 2.5.1)
you can overload __getattr__ in your brain class, but since this class
is on the fly subclassed with the class 'r',
that inherits first from 'Record' that is an extension class that has
its own __getattr__
your __getattr__ never gets called.
regards
phil
Dieter Maurer wrote:
>Jo Meder writes:
> > Situation: I'm developing a product where some attributes come from
> > one bunch of SQL-tables and some additional info is obtained by other
> > means.
> >
> > The idea was to create a brain-class and overwrite __getattr__ to return
> > the correct values from the different sources according to what key the
> > application asked for.
> >
> > The objects are created (just like in DA.py) via
> >
> > objects=Results.Results(result,brain,parent,None)
> >
> > Now whatever I try, either some other __getattr__ seems to be called
> > since I can get none of my "simulated" attributes to show up.
>It should work with modern Zope versions.
>
>I once tried and failed with an older version (Zope 2.1.6).
>My "__getattr__" led to an infinite loop.
>
>
>Dieter
>
>
>_______________________________________________
>Zope maillist - Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>** No cross posts or HTML encoding! **
>(Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
>
>