[Persistence-sig] "Straw Baby" Persistence API

Steve Menard smenard@bigfoot.com
Mon, 22 Jul 2002 12:08:37 -0400


At 11:50 AM 7/22/2002 -0400, Jeremy Hylton wrote:
> >>>>> "SM" == Steve Menard <smenard@bigfoot.com> writes:
>
>   >> > On a side note, as I have said in another post, I have done
>   >> > exactly that, subclassing dict and list. While my model didn't
>   >> > need to override __getitem__(), the __setitem__() at least
>   >> > seemed to act properly. In fact the only problem I have found
>   >> > is that it was not possible to mix __slots__ and dict/list.
>   >>
>   >> For all strange and perverse things I've done, slots work just
>   >> fine when inheriting from list and dict.  Again, can you provide
>   >> an example of where you found otherwise?
>
>   SM> Ok, my problem was from inheriting both from dict and from my
>   SM> Persistent class. Persistent was using slots. I could dig out or
>   SM> reproduce error message if you're interested.
>
>dict and Persistent are not compatible at the C level.  That's a
>second problem, and one that I hadn't thought of.  (It doesn't have
>anything to do with slots.)
>
> >>> class PD(Persistent, dict):
>...     pass
>...
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>TypeError: multiple bases have instance lay-out conflict
>
>There's no way to make this problem go away if we continue to
>implement persistence in C.

Right. That's the same problem I had, even though my Persistent was not 
implemented in C. It simply used __slots__. I guess since __slots__ change 
the layout of the object the same problem is caused.

         Steve