opental-checkins
[Top][All Lists]
Advanced

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

[OpenTAL-checkins] opental/OpenPT OpenPTBase.py


From: Fernando Lalo Martins
Subject: [OpenTAL-checkins] opental/OpenPT OpenPTBase.py
Date: Mon, 06 Oct 2003 17:44:45 -0400

CVSROOT:        /cvsroot/opental
Module name:    opental
Branch:         
Changes by:     Fernando Lalo Martins <address@hidden>  03/10/06 17:44:45

Modified files:
        OpenPT         : OpenPTBase.py 

Log message:
        this should use the new Negotiator to negotiate the charset... pending 
some tests

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/OpenPT/OpenPTBase.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: opental/OpenPT/OpenPTBase.py
diff -u opental/OpenPT/OpenPTBase.py:1.11 opental/OpenPT/OpenPTBase.py:1.12
--- opental/OpenPT/OpenPTBase.py:1.11   Fri Apr 25 12:04:04 2003
+++ opental/OpenPT/OpenPTBase.py        Mon Oct  6 17:44:45 2003
@@ -15,7 +15,7 @@
 #    You should have received a copy of the GNU General Public License
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
-__version__='$Revision: 1.11 $'[11:-2]
+__version__='$Revision: 1.12 $'[11:-2]
 
 # ugh, this import list needs to be cleaned up
 import OpenTAL, pax, PTmetal_handler, pax.paxtransform, Zpax
@@ -50,6 +50,10 @@
 from encodings.aliases import aliases as encoding_aliases
 from DocumentTemplate.DT_Util import TemplateDict, InstanceDict
 from AccessControl.DTML import RestrictedDTML
+try:
+    from PlacelessTranslationService.Negotiator import negotiator
+except:
+    negotiator = None
 my_home = package_home(globals())
 
 class Rtd(RestrictedDTML, TemplateDict):
@@ -533,7 +537,12 @@
                 context.encoding = self.encoding
             context.root_xmlns_map = root_ns_map
             tr_engine.initialize(context)
-            encoding_neg = EncodingNegotiator(self.acceptable_encodings)
+            if negotiator:
+                encoding_neg = 
EncodingNegotiator(negotiator.getAccepted(self.REQUEST, 'charset'))
+                encoding_neg.restrict(self, self.acceptable_encodings)
+            else:
+                # slightly different logic, but good results in practice
+                encoding_neg = EncodingNegotiator(self.acceptable_encodings)
             # we need the acquisition wrapper or AccessControl will squeal
             self.REQUEST.pt_output_encoding = encoding_neg.__of__(self)
             # now run the template




reply via email to

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