[ZODB-Dev] __setstate__ and mixins
Christian Reis
kiko@async.com.br
Mon, 7 Oct 2002 20:52:34 -0300
On Mon, Oct 07, 2002 at 07:48:50PM -0400, Jeremy Hylton wrote:
> CR> You mean a default __setstate__(), I guess. Does it do anything
> CR> useful?
>
> Right. It provides both methods, and they implement the standard
> protocol; e.g. getstate does not return _v_ attributes.
>
> CR> As far as I can understand cPersistence.c, it just does basic
> CR> sanity checking, right?
>
> It provides the implementation.
Sorry, I was unclear. I was referring to cPersistence.c's
Per__setstate__() method (line 317 of current CVS). My quick glance
missed the loop:
for(i=0; PyDict_Next(v, &i, &key, &e);)
if (PyDict_SetItem(__dict__, key, e) < 0)
return NULL;
where it does do something beying goto err (I hope I do understand
cPersistence.c beyond *that* at least :-)
> Regardless, it means that if you have a chain of inheritance that goes
> derived class -> Persistent -> base class, then you're base class's
> __setstate__() isn't going to be called.
I see, which can really only happen when you have multiple inheritance
(depending on the order they are listed in the class definition?) unless
you hack the ZODB itself. Thanks.
Take care,
--
Christian Reis, Senior Engineer, Async Open Source, Brazil.
http://async.com.br/~kiko/ | [+55 16] 261 2331 | NMFL