Michael Dunstan wrote:
Hi all,

I have been trying out ``zope.xmlpickle`` as a alternative to
XMLExportImport in Zope2.

Cool. xmlpickle is really a newer version of the xml pickler used in
Zope 2's export/import.  It's main goal is to provide nicer pickles:

- More readable

- More diff friendly.  It does this my:

  - sorting dictionary items

  - eliminating unused memo references

It would be nice to integrate this back into the export/import
machinery.  Some care would be needed to make it compatible with
the old xml pickles.

> Seems to do the job just fine. Grab Zope
2.9.3 and install zope.xmlpickle by hand using something of the form:

 % cd /opt/Zope-2.9/lib/python/zope
% svn checkout svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/xmlpickle

Then using zopectl debug:

 >>> from zope.xmlpickle import dumps

Picking on something simple to start with:

 >>> xml = dumps(app.acl_users.aq_base)
 >>> print xml
 <?xml version="1.0" encoding="utf-8" ?>
       <global name="__newobj__" module="copy_reg"/>
         <global name="SiteErrorLog"
         <item key="_ignored_exceptions">
         <item key="copy_to_zlog">
         <item key="keep_entries">

That looks okay. But I strike problems with ``Missing.Value`` when
trying this on something that includes a catalog. The simplest way
to recreate the problem::

 >>> import Missing
 >>> dumps(Missing.Value())
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/opt/Zope-2.9/lib/python/zope/xmlpickle/xmlpickle.py", line
146, in dumps
     p = _dumpsUsing_PicklerThatSortsDictItems(ob, 1)
   File "/opt/Zope-2.9/lib/python/zope/xmlpickle/xmlpickle.py", line
73, in _dumpsUsing_PicklerThatSortsDictItems
     _PicklerThatSortsDictItems(file, bin).dump(object)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/pickle.py",
line 231, in dump
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/pickle.py",
line 324, in save
     self.save_global(obj, rv)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/pickle.py",
line 753, in save_global
     module = whichmodule(obj, name)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/pickle.py",
line 825, in whichmodule
     if func in classmap:
 TypeError: unhashable type

Meanwhile, dumps seems to work quite happy with many other examples
that I tried. Including all the content of a plone site minus a couple
of the catalogs. And ``zope.xmlpickle.loads`` seems to do the right thing too.

Any suggestions on getting a successful dumps of a Missing.Value?

You need someone with pickle zen to look at this.  I don't have time
right now myself.  If you don't find any other takers, then put an
issue in the Zope 3 collector.


Jim Fulton           mailto:[EMAIL PROTECTED]       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to