Commit fa4c15f8 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Make it work to just pass UTF-8 strings to the template by decoding all...

Make it work to just pass UTF-8 strings to the template by decoding all strings with UTF-8 to Unicode.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19404 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9fc20992
......@@ -93,6 +93,12 @@ def add_and_edit(self, id, REQUEST):
u = "%s/%s" % (u, quote(id))
REQUEST.RESPONSE.redirect(u+'/manage_main')
class OOoTemplateStringIO(FasterStringIO):
def write(self, s):
if type(s) == unicode:
s = s.encode('utf-8')
FasterStringIO.write(self, s)
class OOoTemplate(ZopePageTemplate):
"""
A page template which is able to embed and OpenOffice
......@@ -156,12 +162,10 @@ class OOoTemplate(ZopePageTemplate):
# we store the attachments of the uploaded document
self.OLE_documents_zipstring = None
# Re-define StringIO with the original one, because iHotfix may
# monkey patch it.
# XXX it might be better to simply disable iHotfix overriding
# StringIO.
# Every OOoTemplate uses UTF-8 or Unicode, so a special StringIO class
# must be used, which does not care about response.
def StringIO(self):
return FasterStringIO()
return OOoTemplateStringIO()
def pt_upload(self, REQUEST, file=''):
"""Replace the document with the text in file."""
......
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