[Checkins] SVN: z3c.pt/trunk/ Language negotiation happens before we start rendering, so we no longer need to explicitly pass in a translation context.

Malthe Borch mborch at gmail.com
Sun Aug 24 07:58:22 EDT 2008


Log message for revision 90170:
  Language negotiation happens before we start rendering, so we no longer need to explicitly pass in a translation context.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/config.py
  U   z3c.pt/trunk/src/z3c/pt/pagetemplate.py
  U   z3c.pt/trunk/src/z3c/pt/translation.py

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-08-24 11:46:17 UTC (rev 90169)
+++ z3c.pt/trunk/CHANGES.txt	2008-08-24 11:58:21 UTC (rev 90170)
@@ -4,6 +4,9 @@
 Version 1.0dev
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- Language negotiation is left to the page template superclass, so we
+  don't need to pass in a translation context anymore. [malthe]
+
 - The ``ViewPageTemplateFile`` class now uses the module path of the
   calling class to get an absolute path to a relative filename passed
   to the constructor. [malthe]

Modified: z3c.pt/trunk/src/z3c/pt/config.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/config.py	2008-08-24 11:46:17 UTC (rev 90169)
+++ z3c.pt/trunk/src/z3c/pt/config.py	2008-08-24 11:58:21 UTC (rev 90170)
@@ -48,7 +48,7 @@
     result = '_result'
     marker = '_marker'
     domain = '_domain'
-    context = '_context'
+    i18n_context = '_i18n_context'
     attributes = '_attributes'
     negotiate = '_negotiate'
     translate = '_translate'

Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2008-08-24 11:46:17 UTC (rev 90169)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2008-08-24 11:58:21 UTC (rev 90170)
@@ -17,7 +17,7 @@
         return
     
     if not target_language:
-        context = kwargs.get('context')
+        context = kwargs.get(config.SYMBOLS.i18n_context)
         target_language = zope.i18n.negotiate(context)
 
         if target_language:
@@ -63,7 +63,6 @@
             return self.template.render(view=view,
                                         context=view.context,
                                         request=view.request,
-                                        _context=view.request,
                                         options=kwargs)
         return template
 

Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py	2008-08-24 11:46:17 UTC (rev 90169)
+++ z3c.pt/trunk/src/z3c/pt/translation.py	2008-08-24 11:58:21 UTC (rev 90170)
@@ -334,7 +334,7 @@
         return msgid
 
     def translate_expression(self, value, mapping=None, default=None):
-        format = "_translate(%s, domain=%%(domain)s, mapping=%s, context=%%(context)s, " \
+        format = "_translate(%s, domain=%%(domain)s, mapping=%s, " \
                  "target_language=%%(language)s, default=%s)"
         return types.template(
             format % (value, mapping, default))
@@ -505,12 +505,6 @@
         for selector in stream.selectors:
             extra += '%s=None, ' % selector
 
-        # we need to ensure we have _context for the i18n handling in
-        # the arguments. the default template implementations pass
-        # this in explicitly.
-        if stream.symbols.context not in params:
-            extra += '%s=None, ' % stream.symbols.context
-
         # wrap generated Python-code in function definition
         body = stream.getvalue()
         mapping = dict(



More information about the Checkins mailing list