[Erp5-report] r19404 - /erp5/trunk/products/ERP5OOo/OOoTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Feb 19 17:31:03 CET 2008


Author: yo
Date: Tue Feb 19 17:31:03 2008
New Revision: 19404

URL: http://svn.erp5.org?rev=19404&view=rev
Log:
Make it work to just pass UTF-8 strings to the template by decoding all strings with UTF-8 to Unicode.

Modified:
    erp5/trunk/products/ERP5OOo/OOoTemplate.py

Modified: erp5/trunk/products/ERP5OOo/OOoTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoTemplate.py?rev=19404&r1=19403&r2=19404&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoTemplate.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoTemplate.py Tue Feb 19 17:31:03 2008
@@ -93,6 +93,12 @@
     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 @@
     # 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."""




More information about the Erp5-report mailing list