Author: mtredinnick
Date: 2007-10-21 12:14:25 -0500 (Sun, 21 Oct 2007)
New Revision: 6582

Modified:
   django/trunk/django/conf/__init__.py
   django/trunk/django/utils/translation/__init__.py
   django/trunk/django/utils/translation/trans_null.py
   django/trunk/django/utils/translation/trans_real.py
   django/trunk/tests/regressiontests/templates/tests.py
Log:
Fixed #2920 -- Removed _() from builtins.

This is backwards incompatible, but easy to work around.


Modified: django/trunk/django/conf/__init__.py
===================================================================
--- django/trunk/django/conf/__init__.py        2007-10-21 16:20:02 UTC (rev 
6581)
+++ django/trunk/django/conf/__init__.py        2007-10-21 17:14:25 UTC (rev 
6582)
@@ -140,13 +140,3 @@
 
 settings = LazySettings()
 
-# This function replaces itself with django.utils.translation.gettext() the
-# first time it's run. This is necessary because the import of
-# django.utils.translation requires a working settings module, and loading it
-# from within this file would cause a circular import.
-def first_time_gettext(*args):
-    from django.utils.translation import gettext
-    __builtins__['_'] = gettext
-    return gettext(*args)
-
-__builtins__['_'] = first_time_gettext

Modified: django/trunk/django/utils/translation/__init__.py
===================================================================
--- django/trunk/django/utils/translation/__init__.py   2007-10-21 16:20:02 UTC 
(rev 6581)
+++ django/trunk/django/utils/translation/__init__.py   2007-10-21 17:14:25 UTC 
(rev 6582)
@@ -8,7 +8,7 @@
         'ngettext_lazy', 'string_concat', 'activate', 'deactivate',
         'get_language', 'get_language_bidi', 'get_date_formats',
         'get_partial_date_formats', 'check_for_language', 'to_locale',
-        'get_language_from_request', 'install', 'templatize', 'ugettext',
+        'get_language_from_request', 'templatize', 'ugettext',
         'ungettext', 'deactivate_all']
 
 # Here be dragons, so a short explanation of the logic won't hurt:
@@ -96,9 +96,6 @@
 def get_language_from_request(request):
     return real_get_language_from_request(request)
 
-def install():
-    return real_install()
-
 def templatize(src):
     return real_templatize(src)
 

Modified: django/trunk/django/utils/translation/trans_null.py
===================================================================
--- django/trunk/django/utils/translation/trans_null.py 2007-10-21 16:20:02 UTC 
(rev 6581)
+++ django/trunk/django/utils/translation/trans_null.py 2007-10-21 17:14:25 UTC 
(rev 6582)
@@ -14,7 +14,7 @@
     return force_unicode(ngettext(singular, plural, number))
 
 activate = lambda x: None
-deactivate = deactivate_all = install = lambda: None
+deactivate = deactivate_all = lambda: None
 get_language = lambda: settings.LANGUAGE_CODE
 get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI
 get_date_formats = lambda: (settings.DATE_FORMAT, settings.DATETIME_FORMAT, 
settings.TIME_FORMAT)

Modified: django/trunk/django/utils/translation/trans_real.py
===================================================================
--- django/trunk/django/utils/translation/trans_real.py 2007-10-21 16:20:02 UTC 
(rev 6581)
+++ django/trunk/django/utils/translation/trans_real.py 2007-10-21 17:14:25 UTC 
(rev 6582)
@@ -249,8 +249,10 @@
 
 def do_translate(message, translation_function):
     """
-    Translate 'message' using the given 'translation_function' name -- which
-    will be either gettext or ugettext.
+    Translates 'message' using the given 'translation_function' name -- which
+    will be either gettext or ugettext. It uses the current thread to find the
+    translation object to use. If no current translation is activated, the
+    message will be run through the default translation object.
     """
     global _default, _active
     t = _active.get(currentThread(), None)
@@ -262,12 +264,6 @@
     return getattr(_default, translation_function)(message)
 
 def gettext(message):
-    """
-    This function will be patched into the builtins module to provide the _
-    helper function. It will use the current thread as a discriminator to find
-    the translation object to use. If no current translation is activated, the
-    message will be run through the default translation object.
-    """
     return do_translate(message, 'gettext')
 
 def ugettext(message):
@@ -414,13 +410,6 @@
         month_day_format = settings.MONTH_DAY_FORMAT
     return year_month_format, month_day_format
 
-def install():
-    """
-    Installs the gettext function as the default translation function under
-    the name '_'.
-    """
-    __builtins__['_'] = gettext
-
 dot_re = re.compile(r'\S')
 def blankout(src, char):
     """

Modified: django/trunk/tests/regressiontests/templates/tests.py
===================================================================
--- django/trunk/tests/regressiontests/templates/tests.py       2007-10-21 
16:20:02 UTC (rev 6581)
+++ django/trunk/tests/regressiontests/templates/tests.py       2007-10-21 
17:14:25 UTC (rev 6582)
@@ -13,7 +13,7 @@
 from django import template
 from django.template import loader
 from django.template.loaders import app_directories, filesystem
-from django.utils.translation import activate, deactivate, install, ugettext 
as _
+from django.utils.translation import activate, deactivate, ugettext as _
 from django.utils.tzinfo import LocalTimezone
 
 from unicode import unicode_tests
@@ -844,8 +844,6 @@
         expected_invalid_str = 'INVALID'
 
         for name, vals in tests:
-            install()
-
             if isinstance(vals[2], tuple):
                 normal_string_result = vals[2][0]
                 invalid_string_result = vals[2][1]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to