[Zope] ZSQL Pluggable brains broke in later Zope, can't add instance attributes
Chris McDonough
chrism@digicool.com
Thu, 5 Jul 2001 13:48:52 -0400
I'm actually sort of surprised that it used to work at all.. I'd imagine
that AttributeError is on the eventtime attr, right? Though I haven't
looked at the code, from your description, it would seem that the pluggable
brains stuff makes a class instance and then stuffs in the attrs... the
__init__ method would get called at instantiation time before the class
attrs existed, causing the attributeerror.
Would it be possible to use an "init()" method on the brain object, a custom
__getattr__, or a computed attribute (see
http://debian.acm.ndsu.nodak.edu/doc/python-extclass/ExtensionClass.html ,
search for computed attribute) instead of trying to precompute the attr?
You could cache the return value on the first call if you used a custom
__getattr__ or a computed attribute.
- C
----- Original Message -----
From: "Brad Clements" <bkc@murkworks.com>
To: "Chris McDonough" <chrism@digicool.com>
Cc: <zope@zope.org>
Sent: Thursday, July 05, 2001 1:37 PM
Subject: Re: [Zope] ZSQL Pluggable brains broke in later Zope, can't add
instance attributes
> On 5 Jul 2001, at 13:02, Chris McDonough wrote:
>
> > Is eventday acquired or something?
> >
>
> Sorry, here's the full class, eventtime is an SQL column
>
>
> class PackageEvent:
> """Package Event Pluggable Brain"""
> def __init__(self):
> """initialize"""
> self.eday = self.eventday()
> # setattr(self,'eday',self.eventday())
> # self.__dict__['eday'] = self.eventday()
>
> def eventday(self):
> return
DateTime(apply(time.mktime,self.eventtime.tuple()[:3]+(0,0,0,0,0,-1)))
>
>
>