Ticket #8033: better_error_handling_for_ugettext_r8138.3.diff

File better_error_handling_for_ugettext_r8138.3.diff, 2.8 KB (added by Manuel Saelices, 16 years ago)

This patch fixes apache problems, forcing apps loading just in request processing

  • django/core/handlers/base.py

     
    6262        "Returns an HttpResponse object for the given HttpRequest"
    6363        from django.core import exceptions, urlresolvers
    6464        from django.conf import settings
     65        from django.db.models.loading import get_apps
    6566
     67        # Force app loading
     68        get_apps()
     69
    6670        # Apply request middleware
    6771        for middleware_method in self._request_middleware:
    6872            response = middleware_method(request)
  • 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/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/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, get_apps
    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 \
     276       not isinstance(t, gettext_module.NullTranslations):
     277        raise ImproperlyImplemented(
     278            "django.utils.translation.%(func_name)s function called at "
     279            "import time to perform a translation of '%(message)s'. "
     280            "%(func_name)s function must be called after "
     281            "applications loading." % {'func_name': translation_function,
     282                                       'message': message})
    273283    if t is not None:
    274284        result = getattr(t, translation_function)(message)
    275285    else:
Back to Top