Ticket #8033: better_error_handling_for_ugettext_r8138.2.diff

File better_error_handling_for_ugettext_r8138.2.diff, 2.2 KB (added by Manuel Saelices, 16 years ago)

A better patch... but It's seems to have problems in apache detection of app_cache_ready

  • django/views/debug.py

     
    6060
    6161    def get_traceback_html(self):
    6262        "Return HTML code for traceback."
     63        from django.utils import translation
     64        translation.deactivate_all() # avoid possible translation errors in 500 error handling
    6365
    6466        if issubclass(self.exc_type, TemplateDoesNotExist):
    6567            from django.template.loader import template_source_loaders
  • django/core/exceptions.py

     
    2828    "Django is somehow improperly configured"
    2929    pass
    3030
     31class ImproperlyImplemented(Exception):
     32    "Django is somehow improperly implemented"
     33    pass
     34
    3135class FieldError(Exception):
    3236    """Some kind of problem with a model field."""
    3337    pass
  • django/utils/translation/trans_real.py

     
    77import gettext as gettext_module
    88from cStringIO import StringIO
    99
     10from django.core.exceptions import ImproperlyImplemented
     11from django.db.models.loading import app_cache_ready
    1012from django.utils.safestring import mark_safe, SafeData
    1113from django.utils.thread_support import currentThread
    1214
     
    270272    """
    271273    global _default, _active
    272274    t = _active.get(currentThread(), None)
     275    if not app_cache_ready() and not isinstance(t, gettext_module.NullTranslations):
     276        raise ImproperlyImplemented(
     277            "django.utils.translation.%(func_name)s function called at "
     278            "import time to perform a translation of '%(message)s'. "
     279            "%(func_name)s function must be called after "
     280            "applications loading." % {'func_name': translation_function,
     281                                       'message': message})
    273282    if t is not None:
    274283        result = getattr(t, translation_function)(message)
    275284    else:
Back to Top