[Zope-dev] Re: XML export/import is cool! (Was Re: Deprecating XML export/import?)

2006-03-26 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yoshinori Okuji wrote:
 On Saturday 25 March 2006 15:56, Andreas Jung wrote:
 
Zope 2.7 throws a BadPickleGet, 12 exception, Zope 2.8 throws
BadPickleGet, 13 and Zope 2.9 raises the described UnicodeDecodeError.
I don't expect that the import functionality works for even more complex
objects. So I consider the whole functionality as totally broken. The
generated XML might be useful to perform any processing outside Zope but
using it for re-importing it into another Zope systems definitely does
_not_  work. So if the functionality should remain in Zope then it should
be fixed
for Zope 2.10 lately.
 
 
 Here is a quick patch for this problem (against 2.9.1). There were two 
 different problems:
 
 - the id attributes were not generated, because the conditional was reverse.
 
 - unlike xmllib, expat always returns Unicode data, so simply concatenating 
 binary values generates Unicode objects with non-ascii characters.
 
 For the latter problem, I'm not sure if my patch is enough. But this patch 
 works with a simple dtml export/import.

I have extended your patch with a unit test (there weren't any for
OFS.XMLExportImport), as well as modifying XMLExportImport to open files
in binary mode.  Before your patch, my tests fail, with the same Unicode
error.  Afterwards, they pass.



Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEJuQf+gerLs4ltQ4RAjaRAJ9tT6Xv0yIJpPx2SixFSKdghtVcrwCfU6Yk
VrofPZTcbr1RzTu5knxSwJs=
=mRAe
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: XML export/import is cool! (Was Re: Deprecating XML export/import?)

2006-03-25 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Andreas Jung wrote:

 --On 24. März 2006 11:07:06 -0500 Jim Fulton [EMAIL PROTECTED] wrote:
 

 - it was broken multiple times in the past, it still has problems

 How so?
 
 The import functionality seem to be broken since at least Zope 2.7.
 
 I created a DTML method exported it and _tried_ to reimport it.
 
 Zope 2.7 throws a BadPickleGet, 12 exception,

I just exported the stock 'standard_error_message' as XML and
re-imported it successfully in a brand new Zope-2_7-branch instance.

 Zope 2.8 throws BadPickleGet, 13

Likewise, my import succeeded in a Zope-2_8-instance, both with the XML
file exported from 2.7 and with one created from 2.8.

 Zope 2.9 raises the described UnicodeDecodeError.

My Zope-2_9-branch instance was successfully able to import the XML file
from 2.7, but raises a UnicodeDecode error on the file it produces, as
well as the one created from 2.8.  The stack trace here makes it seem as
though Python 2.4.2's expat parser is at fault:  it is introducing
non-ASCII characters into the stream where none exist in the source:

(Pdb) u
/home/tseaver/projects/Zope-CVS/Zope-2_9-branch/lib/python/OFS/XMLExportImport.py(114)importXML()
- - r=p.Parse(data)
(Pdb) print [x for x in data if ord(x)  127]
[]
(Pdb) d

/home/tseaver/projects/Zope-CVS/Python-2.4.3c1/Modules/pyexpat.c(639)EndElement()
- - ((N), string_intern(self, name)))
(Pdb) d

/home/tseaver/projects/Zope-CVS/Zope-2_9-branch/lib/python/Shared/DC/xml/xyap.py(58)unknown_endtag()
- - top = end[tag](self, tag, top)
(Pdb) print [type(x) for x in top]
[type 'unicode', type 'dict', type 'unicode', type 'str']
(Pdb) print [x for x in top[-1] if ord(x)  127]
['\xcb']
(Pdb) print [chr(ord(x)) for x in top[-1][10:25]]
['U', '\x03', 'r', 'a', 'w', 'T', '\xcb', '\x04', '\x00', '\x00', '',
'd', 't', 'm', 'l']

That output seems to me to indicate that the start of the CDATA section
is the problem.

 I don't expect that the import functionality works for even more complex
 objects. So I consider the whole functionality as totally broken. The
 generated XML might be useful to perform any processing outside Zope but
 using it for re-importing it into another Zope systems definitely does
 _not_  work. So if the functionality should remain in Zope then it
 should be fixed for Zope 2.10 lately.

I've just tried again, running with Python 2.4.3c1, because several of
the changelog entries for the release suggest that unicode / encoding /
expat stuff may have been fixed:  the decode error is still present.


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEJZsA+gerLs4ltQ4RArirAKC+a8k1GBTrujZ2uu5hygxnkSk9HACeLiAK
n+8RTUlzAnsdBAkTDQ730mk=
=6CcM
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Re: XML export/import is cool! (Was Re: Deprecating XML export/import?)

2006-03-24 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Jim Fulton wrote:
 Andreas Jung wrote:

snip

 E.g. on the Plone/Archetypes level
 
 we have some mechanisms to export/import data defined through schemas 
 
 That's a good point. For Archetypes-based apps, this might be the way
 to go.  I think that xml-pickle export is a reasonable approach
 for other apps.

The XML export format is conceptually like the system view XML mapping
defined by JSR-170[1], as opposed to the document view mapping, which
is more like the CMFSetup content export (and related Archetypes /
Marshall ) formats.

 (possibly
 we have something in Zope 3 (at least I once wrote a similar solution
 for Zope 3). The export/import mechanism is basically for moving data
 from one
 Zope instance to another instance. It should work in a reliable way
 and should not try to solve issues that should be solved on another
 level.
 
 The unfinished fssync tool in Zope 3 is intended for this use case.
 It to uses an improved xmlpickle as a fallback.  It would be nice to
 finish this, however, I can easily XSLT gun slingers prefering something
 like xml export.

[1] http://jcp.org/aboutJava/communityprocess/final/jsr170/index.html


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEJGMc+gerLs4ltQ4RArckAJ43rneghtA6TjyolVXJQq71BZ3uTwCfYXMk
+rZYS14HXLkZZ/exnN+FCII=
=ghB3
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )