Update with pickle
Matteo Dell'Amico
della at toglimi.linux.it
Thu May 27 11:20:30 EDT 2004
Stefan Seefeld wrote:
> Think of a 'persistence storage service' that could look like this:
>
> store = Persistence.Store('foobar')
>
> object.store(store) # persists the object's state into the store
>
> ...
>
> object.restore(store) # restore the object's state from the store
>
> Of course, here 'object' has to implement some 'Storable' interface,
> so it's quite intrusive (and thus not really what Nicolas is looking for).
> It's just to illustrate the purpose, anyways.
> With python's metaprogramming and introspection capabilities the same
> could be achieved without the need for a specific base class. Well,
> may be a specific __metaclass__, I don't know.
>
> It really seems to me that pickle already contains the functionality
> that would be required (after all pickle *can* deal with object graphs,
> so it has to track object ids internally), it just needs to be exposed
> to the user. I believe that's precisely what Nicolas' enhancement request
> is all about.
Now I understand. If you always use it for restoring a previous state
for the same object, it even looks less evil to me :-) Maybe a metaclass
with some kind transactions and rollback could be interesting...
--
Ciao,
Matteo
More information about the Python-list
mailing list