[ZODB-Dev] Import/Export code

David Binger dbinger at mems-exchange.org
Wed Aug 15 09:44:42 EDT 2007


On Aug 15, 2007, at 9:34 AM, Christian Theune wrote:

>             pfile = StringIO(data)
>             unpickler = Unpickler(pfile)
>             unpickler.persistent_load = persistent_load
>
>             newp = StringIO()
>             pickler = Pickler(newp, 1)
>             pickler.persistent_id = persistent_id
>
>             pickler.dump(unpickler.load())
>             pickler.dump(unpickler.load())
>             data = newp.getvalue()
>
> Why do we call pickler.dump(unpickler.load()) twice?

Just a guess, but I think it is because the original data record is  
actually
the concatenation of two pickles, the first for the class (or something
like that) and the second is the actual pickled object state.
It looks like this code extracts the pickled state from the record.





More information about the ZODB-Dev mailing list