[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/ Merged from trunk:

Jim Fulton jim at zope.com
Thu Jul 8 15:19:10 EDT 2004


Log message for revision 26220:
Merged from trunk:

r26164 | jim | 2004-07-07 12:51:50 -0400 (Wed, 07 Jul 2004) | 4 lines

Deprecated passing a(n ignored) location argument to translate

This resolves an XXX.



-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/form/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/__init__.py	2004-07-08 19:12:58 UTC (rev 26219)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/__init__.py	2004-07-08 19:19:10 UTC (rev 26220)
@@ -42,8 +42,7 @@
         self.context.description))
     
     def _translate(self, text):
-        return translate(self.context, text, "zope",
-                         context=self.request, default=text)
+        return translate(text, "zope", context=self.request, default=text)
             
     def _renderedValueSet(self):
         """Returns True if the the widget's rendered value has been set.

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/itemswidgets.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/itemswidgets.py	2004-07-08 19:12:58 UTC (rev 26219)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/itemswidgets.py	2004-07-08 19:19:10 UTC (rev 26220)
@@ -62,8 +62,7 @@
     """A mixin class that provides the translation capabilities."""
 
     def translate(self, msgid):
-        return translate(self.context, msgid, context=self.request,
-                         default=msgid)
+        return translate(msgid, context=self.request, default=msgid)
 
 def message(msgid, default):
     """Add a default value to a i18n message id."""

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/sequencewidget.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/sequencewidget.py	2004-07-08 19:12:58 UTC (rev 26219)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/form/browser/sequencewidget.py	2004-07-08 19:19:10 UTC (rev 26220)
@@ -82,15 +82,15 @@
         if render and num_items > min_length:
             remove_botton_name = 'remove-selected-items-of-seq-' + self.name
             button_label = _('remove-selected-items', "Remove selected items")
-            button_label = translate(self.context, button_label,
-                                     context=self.request, default=button_label)
+            button_label = translate(button_label, context=self.request,
+                                     default=button_label)
             buttons += '<input type="submit" value="%s" name="%s"/>' % (
                 button_label, remove_botton_name)
         if max_length is None or num_items < max_length:
             field = self.context.value_type
             button_label = _('Add %s')
-            button_label = translate(self.context, button_label,
-                                     context=self.request, default=button_label)
+            button_label = translate(button_label, context=self.request,
+                                     default=button_label)
             button_label = button_label % (field.title or field.__name__)
             buttons += '<input type="submit" name="%s.add" value="%s" />' % (
                 self.name, button_label)

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/pagetemplate/engine.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/pagetemplate/engine.py	2004-07-08 19:12:58 UTC (rev 26219)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/pagetemplate/engine.py	2004-07-08 19:19:10 UTC (rev 26220)
@@ -82,7 +82,7 @@
         # When running Zope, request is a Proxy, but no mutation is done here,
         # so it is safe to remove all proxies
         request = removeAllProxies(self.request)
-        return translate(self.context, msgid, domain, mapping,
+        return translate(msgid, domain, mapping,
                          context=request, default=default)
 
     evaluateInlineCode = False

Modified: Zope3/branches/ZopeX3-3.0/src/zope/i18n/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/i18n/__init__.py	2004-07-08 19:12:58 UTC (rev 26219)
+++ Zope3/branches/ZopeX3-3.0/src/zope/i18n/__init__.py	2004-07-08 19:19:10 UTC (rev 26220)
@@ -16,6 +16,7 @@
 $Id$
 """
 import re
+import warnings
 from zope.i18nmessageid import MessageIDFactory, MessageID
 from zope.i18n.interfaces import ITranslationDomain
 
@@ -28,19 +29,17 @@
 _get_var_regex = re.compile(r'%(n)s' %({'n': NAME_RE}))
 
 
-# XXX: location not needed
-def translate(location, msgid, domain=None, mapping=None, context=None,
-              target_language=None, default=None):
+def _translate(msgid, domain=None, mapping=None, context=None,
+               target_language=None, default=None):
 
-    # XXX: For some reason, I get a recursive import when placing this import
-    #      outside the function. I have no clue how to fix this. SR
-    from zope.component import queryUtility
 
     if isinstance(msgid, MessageID):
         domain = msgid.domain
         default = msgid.default
         mapping = msgid.mapping
 
+    # XXX we shouldn't need this import here
+    from zope.component import queryUtility
     util = queryUtility(ITranslationDomain, domain)
 
     if util is None:
@@ -48,7 +47,19 @@
 
     return util.translate(msgid, mapping, context, target_language, default)
 
+# BBB Backward compat
+def translate(*args, **kw):
+    if args and not isinstance(args[0], basestring):
+        warnings.warn(
+            "translate no longer takes a location argument. "
+            "The argument was ignored.",
+            DeprecationWarning, 2)
+        args = args[1:]
+    return _translate(*args, **kw)
 
+    
+
+
 def interpolate(text, mapping):
     """Insert the data passed from mapping into the text"""
 



More information about the Zope3-Checkins mailing list