Performance improvement in XML marshaller by mimicking StringIO in unicode-friendly buffer UnicodeBuffer and added a class appy.gen.No allowing to explain why some workflow condition cannot be triggered.

This commit is contained in:
Gaetan Delannay 2010-02-05 15:39:52 +01:00
parent 50619f28c0
commit d398d5bcfc
4 changed files with 20 additions and 7 deletions

View file

@ -41,15 +41,17 @@ class UnicodeBuffer:
'''With StringIO class, I have tons of encoding problems. So I define a
similar class here, that uses an internal unicode buffer.'''
def __init__(self):
self.buffer = u''
self.buffer = []
def write(self, s):
if s == None: return
if isinstance(s, unicode):
self.buffer += s
self.buffer.append(s)
elif isinstance(s, str):
self.buffer += s.decode('utf-8')
self.buffer.append(s.decode('utf-8'))
else:
self.buffer += unicode(s)
self.buffer.append(unicode(s))
def getValue(self):
return u''.join(self.buffer)
# ------------------------------------------------------------------------------
class Dummy: pass

View file

@ -503,7 +503,7 @@ class XmlMarshaller:
self.marshallSpecificElements(instance, res)
# Return the result
res.write('</'); res.write(self.rootElementName); res.write('>')
res = res.buffer
res = res.getValue()
if not self.dumpUnicode:
res = res.encode('utf-8')
return res