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.

Yoshinori Okuji, Nexedi CTO
Nexedi: Consulting and Development of Free / Open Source Software
ERP5: Full Featured High End Open Source ERP
ERP5 Wiki: Developer Zone for ERP5 Community
diff -urN Zope-2.9.1.orig/Dependencies/Shared-Zope-2.9.1/Shared/DC/xml/ppml.py Zope-2.9.1/Dependencies/Shared-Zope-2.9.1/Shared/DC/xml/ppml.py
--- Zope-2.9.1.orig/Dependencies/Shared-Zope-2.9.1/Shared/DC/xml/ppml.py	2006-03-15 17:11:00.000000000 +0100
+++ Zope-2.9.1/Dependencies/Shared-Zope-2.9.1/Shared/DC/xml/ppml.py	2006-03-25 21:31:25.183545415 +0100
@@ -414,14 +414,14 @@
     def load_binput(self):
         i = mloads('i' + self.read(1) + '\000\000\000')
         last = self.stack[-1]
-        if getattr(last, 'id', last) is not last:
+        if getattr(last, 'id', last) is last:
             last.id = self.idprefix + `i`
     dispatch[BINPUT] = load_binput
     def load_long_binput(self):
         i = mloads('i' + self.read(4))
         last = self.stack[-1]
-        if getattr(last, 'id', last) is not last:
+        if getattr(last, 'id', last) is last:
             last.id = self.idprefix + `i`
     dispatch[LONG_BINPUT] = load_long_binput
@@ -643,10 +643,10 @@
         'pickle': lambda self, tag, attrs: [tag, attrs],
-        'pickle': lambda self, tag, data: data[2]+'.',
+        'pickle': lambda self, tag, data: str(data[2])+'.',
         'none': lambda self, tag, data: 'N',
         'int': save_int,
-        'long': lambda self, tag, data: 'L'+data[2]+'L\012',
+        'long': lambda self, tag, data: 'L'+str(data[2])+'L\012',
         'float': save_float,
         'string': save_string,
         'reference': save_reference,
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to