opental-checkins
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OpenTAL-checkins] opental/PlacelessTranslationService PlacelessTr...


From: Fernando Lalo Martins
Subject: [OpenTAL-checkins] opental/PlacelessTranslationService PlacelessTr...
Date: Fri, 14 Feb 2003 15:38:55 -0500

CVSROOT:        /cvsroot/opental
Module name:    opental
Changes by:     Fernando Lalo Martins <address@hidden>  03/02/14 15:38:55

Modified files:
        PlacelessTranslationService: PlacelessTranslationService.py 

Log message:
        this should make it work even with a broken ZPT, no more UnicodeErrors 
(at least I couldn't produce one)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/PlacelessTranslationService/PlacelessTranslationService.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: opental/PlacelessTranslationService/PlacelessTranslationService.py
diff -u opental/PlacelessTranslationService/PlacelessTranslationService.py:1.9 
opental/PlacelessTranslationService/PlacelessTranslationService.py:1.10
--- opental/PlacelessTranslationService/PlacelessTranslationService.py:1.9      
Wed Jan 29 17:40:24 2003
+++ opental/PlacelessTranslationService/PlacelessTranslationService.py  Fri Feb 
14 15:38:55 2003
@@ -17,7 +17,7 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 """Placeless Translation Service for providing I18n to file-based code.
 
-$Id: PlacelessTranslationService.py,v 1.9 2003/01/29 22:40:24 lalo Exp $
+$Id: PlacelessTranslationService.py,v 1.10 2003/02/14 20:38:55 lalo Exp $
 """
 
 import re, zLOG
@@ -25,7 +25,11 @@
 from Negotiator import negotiator
 from Domain import Domain
 import os
-from pax import XML
+try:
+    from pax import XML
+except:
+    def XML(v):
+        return str(v)
 
 def log(msg, severity=zLOG.INFO, detail='', error=None):
     zLOG.LOG('PlacelessTranslationService', severity, msg, detail, error)
@@ -137,8 +141,14 @@
                 # it's not in this catalog, try the next one
                 continue
             # found! negotiate output encodings now
-            if hasattr(context, 'pt_output_encoding') and 
catalog.preferred_encodings:
-                context.pt_output_encoding.restrict(catalog, 
catalog.preferred_encodings)
+            if hasattr(context, 'pt_output_encoding'):
+                # OpenPT
+                if catalog.preferred_encodings:
+                    context.pt_output_encoding.restrict(catalog, 
catalog.preferred_encodings)
+            else:
+                # ZPT probably
+                # ask HTTPResponse to encode it for us
+                text = context.RESPONSE._encode_unicode(text)
             break
         else:
             # Did the fallback fail?  Sigh, use the default.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]