[ZODB-Dev] Persisting oher stuff than persistent objects...

Jeremy Hylton jeremy@zope.com
Wed, 26 Jun 2002 12:47:19 -0400


> Of Magnus Lycka
> I'm trying to figure out how to get away with
> using a sub class of string in ZODB. Making a
> class which sub classes both Persistence.Persistent
> and str seems impossible.

You're right that it is impossible to create a class that subclasses
both Persistent and a built-in type.  Since persistent defines a
custom C layout, it is not compatible with any of the other built-in
types like string, list, or dict.  Even if you could create such a
subclass, it is not clear that you would want to.  The string is
immutable so persistence doesn't buy much.  The built-in lists and
dict types can be modified by the interpreter without notifying your
subclass.  For example, any C code that calls PyDict_SetItem will
modify the dictionary but not set _p_changed or call any subclass
method that would set _p_changed.
 
> Is there another way date do this? If I just sub
> class str, can I still make these objects persist
> in ZODB? I can obviously make objects such as

You can use UserString.

Jeremy