[Erp5-report] r41523 jm - /erp5/trunk/products/ERP5Type/patches/ppml.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Dec 18 18:31:46 CET 2010


Author: jm
Date: Sat Dec 18 18:31:46 2010
New Revision: 41523

URL: http://svn.erp5.org?rev=41523&view=rev
Log:
Really fix random failures in testBusinessTemplate on Zope 2.12

Commit 40325 was only optimization.
ppml.String objects (for mapped oids) are still "built" (= __init__) with the
original oid, and depending on the datetime, this oid could have a shorter
representation in 'repr' encoding instead of 'base64'.

Modified:
    erp5/trunk/products/ERP5Type/patches/ppml.py

Modified: erp5/trunk/products/ERP5Type/patches/ppml.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/ppml.py?rev=41523&r1=41522&r2=41523&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/ppml.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/ppml.py [utf8] Sat Dec 18 18:31:46 2010
@@ -127,28 +127,32 @@ class Immutable:
         return self.value
 
 class String(Scalar):
+
+    encoding = None
+
     def __init__(self, v, mapping, encoding=''):
-        encoding, v = convert(v)
-        self.encoding=encoding
         self._v=v
         self.mapping = mapping
+
     def __str__(self,indent=0,map_value=0):
-        v = self.value()
-        if map_value:
-            # This is used when strings represent references which need to be converted
-            if self.encoding == 'base64':
-                v = self.mapping.convertBase64(v)
+        encoding = self.encoding
+        if encoding is None:
+            # lazy conversion
+            if map_value:
+                # This is used when strings represent references which need to
+                # be converted.
+                encoding = 'base64'
+                v = base64.encodestring(self._v)[:-1]
+                self._v = self.mapping.convertBase64(v)
             else:
-                # Make sure we never produce this kind of xml output
-                # XXX: In fact, this can happen when DemoStorage is used
-                #      See notes in XMLExportImport.exportXML
-                raise NotImplementedError
+                encoding, self._v = convert(self._v)
+            self.encoding = encoding
+        v = self.value()
         id = ''
-        encoding=''
-        if hasattr(self, 'encoding'):
-            if self.encoding != 'repr':
-                # JPS repr is default encoding
-                encoding=' encoding="%s"' % self.encoding
+        if encoding == 'repr':
+            encoding = '' # JPS repr is default encoding
+        else:
+            encoding = ' encoding="%s"' % encoding
         name=string.lower(self.__class__.__name__)
         result = '<%s%s%s>%s</%s>' % (name, id, encoding, v, name)
         if hasattr(self, 'id'):



More information about the Erp5-report mailing list