Commit 3b2c96d4 authored by Julien Muchembled's avatar Julien Muchembled

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'.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41523 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fc99faaf
...@@ -127,28 +127,32 @@ class Immutable: ...@@ -127,28 +127,32 @@ class Immutable:
return self.value return self.value
class String(Scalar): class String(Scalar):
encoding = None
def __init__(self, v, mapping, encoding=''): def __init__(self, v, mapping, encoding=''):
encoding, v = convert(v)
self.encoding=encoding
self._v=v self._v=v
self.mapping = mapping self.mapping = mapping
def __str__(self,indent=0,map_value=0): def __str__(self,indent=0,map_value=0):
v = self.value() encoding = self.encoding
if map_value: if encoding is None:
# This is used when strings represent references which need to be converted # lazy conversion
if self.encoding == 'base64': if map_value:
v = self.mapping.convertBase64(v) # 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: else:
# Make sure we never produce this kind of xml output encoding, self._v = convert(self._v)
# XXX: In fact, this can happen when DemoStorage is used self.encoding = encoding
# See notes in XMLExportImport.exportXML v = self.value()
raise NotImplementedError
id = '' id = ''
encoding='' if encoding == 'repr':
if hasattr(self, 'encoding'): encoding = '' # JPS repr is default encoding
if self.encoding != 'repr': else:
# JPS repr is default encoding encoding = ' encoding="%s"' % encoding
encoding=' encoding="%s"' % self.encoding
name=string.lower(self.__class__.__name__) name=string.lower(self.__class__.__name__)
result = '<%s%s%s>%s</%s>' % (name, id, encoding, v, name) result = '<%s%s%s>%s</%s>' % (name, id, encoding, v, name)
if hasattr(self, 'id'): if hasattr(self, 'id'):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment