[ZODB-Dev] Import/Export code

Jim Fulton jim at zope.com
Wed Aug 15 09:59:51 EDT 2007


On Aug 15, 2007, at 9:44 AM, David Binger wrote:

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

Yup. Exactly right,

Jim

--
Jim Fulton			mailto:jim at zope.com		Python Powered!
CTO 				(540) 361-1714			http://www.python.org
Zope Corporation	http://www.zope.com		http://www.zope.org





More information about the ZODB-Dev mailing list