[Zope] Re: adding a custom attribute to a mybrain object
Florent Guillaume
fg at nuxeo.com
Wed Jan 4 16:14:19 EST 2006
Huron wrote:
> I'd like to sort of add some metadata to a returned mybrain before it gets
> handed to the skin for display.
> I've been thinking that it could be possible to just do a 'setattr' on my
> mybrain ... but it's not working since the brain is a very special object
> relatively to it's attributes (from what I understand browsing the code).
> It there a way to do that properly ?
Brains are based on Record, a class dating back to the origins of zope.
Records are quite... peculiar, let's say. They only allow setting
attributes which are in their class's __record_schema__. Go figure.
If I had your problem, I'd copy all the brain attributes on an instance
of another trivial class deriving from object. brain.__record_schema__
will come in handy there.
Florent
--
Florent Guillaume, Nuxeo (Paris, France) Director of R&D
+33 1 40 33 71 59 http://nuxeo.com fg at nuxeo.com
More information about the Zope
mailing list