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