In a bit of a pickle here :)

Shalabh Chaturvedi shalabh at
Wed Nov 26 05:49:34 CET 2003

> I have one other question about the pickle system.  If I add new
> attributes to an object and try to unpickle an old version will it
> work?  How do you handle versioning of objects with pickle?

Your unpickle will succeed but any new attributes will not be present.
The object will get unpickled with exactly the same attributes it had
when it was pickled. Look at __getstate__() and __setstate__() in the
Python docs - you might be able to fix the unpickled object by
overriding __setstate__().

> So I came up with the idea of just
> storing all of the python objects in the postgres database pickled in
> a blob field.  Im sure about ten thousand other people came up with
> this idea before me.  The only other data stored in the table will be
> the id of the object and the last time the object was modified.

What kind of attributes do your objects have? If they point to each
other, or to common objects, then pickling and unpickling can lead to
all sorts of undesirable effects, and you might be better of using a
different solution.

You might want to look at the following (some of which I have never
looked at myself):

1. ZODB (object database of )
2. MiddleKit in Webware ( )
3. Twisted ( )
4. Metakit ( )


More information about the Python-list mailing list