[ZODB-Dev] ExportImport.py: failing on import of extension class
Paul Winkler
pw_lists at slinkp.com
Thu Apr 26 02:13:31 EDT 2007
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?
I ask because I'm trying to get a .zexp imported, but I get this
exception during the *second* of those two lines:
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 85, 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 copy_reg, line 92, in __newobj__
AttributeError: ('__new__', <function __newobj__ at 0x2b9bb93cf140>,
(<extension class Products.Archetypes.Schema.Schema at
2b9bbdf6c9d0>,))
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__
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). And Zope 2.7 pre-dates the switch to new-style
extension classes...doesn't it??
So I don't understand what's happening. I'd expect the .zexp to
contain only old-style extension classes which did not have a __new__
method.
Would this be explained if I'm misinformed about the originating zope
version? I wish I had more access to the original host, but I
don't... I'm just trying to pick up the pieces with what I've been
given.
--
Paul Winkler
http://www.slinkp.com
More information about the ZODB-Dev
mailing list