Paul Winkler wrote at 2007-4-26 02:13 -0400:
>In ExportImport._importDuringCommit() I found this little gem:
>
>            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()
>
>
>What's with the two load-and-dump lines near the end?

They effectively copy the data as a pickle to "newp" mapping the
persistent ids appropriately.

> ...
>If I switch from cPickle to Pickle, I get an extra two lines of
>traceback:
>
>Traceback (innermost last):
>  Module ZPublisher.Publish, line 101, in publish
>  Module ZPublisher.mapply, line 88, in mapply
>  Module ZPublisher.Publish, line 39, in call_object
>  Module OFS.ObjectManager, line 543, in manage_importObject
>  Module OFS.ObjectManager, line 560, in _importObjectFromFile
>  Module ZODB.ExportImport, line 86, in importFile
>  Module ZODB.Transaction, line 241, in commit
>  Module ZODB.Transaction, line 356, in _commit_objects
>  Module ZODB.Connection, line 344, in commit
>  Module ZODB.ExportImport, line 153, in _importDuringCommit
>  Module pickle, line 872, in load
>  Module pickle, line 1153, in load_reduce
>  Module copy_reg, line 95, in __newobj__
>AttributeError: __new__

Execute this in an interactive interpreter and check what "cls" in
"cls.__new__" is (using "pdb.pm()").

> ...
>Evidently, copy_reg.__newobj__() is for use with new-style classes.
>But that's weird, because the guy that gave me this .zexp says that it
>comes from a Zope 2.7 instance (Python 2.3, Plone 2.0) and I'm trying
>to load it into an instance with the same versions (he gave me a
>Products tarball too).

The python versions might differ.



-- 
Dieter
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to