[Persistence-sig] "Straw Baby" Persistence API

Steve Menard smenard@bigfoot.com
Mon, 22 Jul 2002 11:41:36 -0400


At 10:59 AM 7/22/2002 -0400, Kevin Jacobs wrote:
>On Mon, 22 Jul 2002, Steve Menard wrote:
> > At 10:05 AM 7/22/2002 -0400, Jeremy Hylton wrote:
> > >One small comment.  (I owe more substantial comment on Phillip's
> > >earlier proposals.)  The persistent versions of dict and list can't
> > >extend the builtin types, because they need to hook __getitem__() and
> > >__setitem__().  The overridden methods may not be called if we extend
> > >the builtin types.
> >
> > hum, if those method are not guaranteed to be called by subclassing 
> dict or
> > list, then there is something broken. Either that or there is a subtle
> > thing I do not understand.
>
>In fact, I am quite sure that one can inherit from list or dict and override
>__getitem__ and __setitem__ in a cooperative fashion.  Can you provide a
>little more information on why you think otherwise?
Mater of fact, I do not think otherwise. Jeremy said :

"The overridden methods may not be called if we extend the builtin types."

Which I think is wrong.


> > 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?

Ok, my problem was from inheriting both from dict and from my Persistent 
class. Persistent was using slots. I could dig out or reproduce error 
message if you're interested.


         Steve