On Thu, Apr 26, 2007 at 10:10:17AM -0400, Jim Fulton wrote:
> On Apr 26, 2007, at 2:13 AM, Paul Winkler wrote:
> 
> >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?
> 
> It is transforming the pickles by assigning new object ids to the  
> objects imported.
> The unpickler unpickles the pickles into an internal format that can  
> be creates without actually creating the original objects.  It  
> collects object ids and reassigns them. The pickler then turns the  
> internal data back into pickles with the new object ids.
> This is done in 2 steps because database records consist of 2  
> pickles.  The first has enough information to create a ghost. The  
> second pickle contains the object state.

Ah, thanks! So that means my import is succeeding with the ghost
and failing on object state.

Any ideas how to troubleshoot the failure in copy_reg.__newobj__?
Why is a pickle of an old-style extension class getting run through
copy_reg.__newobj__() which only works on new-style classes?
(Or am I misinterpreting the problem?)
Is this likely a sign of software version skew?
Or what?

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__

-- 

Paul Winkler
http://www.slinkp.com
_______________________________________________
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