Ticket #13090: 13090.diff

File 13090.diff, 1.8 KB (added by Ivan Sagalaev, 15 years ago)

Patch

  • django/core/handlers/base.py

     
    7070
    7171        try:
    7272            try:
    73                 # Reset the urlconf for this thread.
    74                 urlresolvers.set_urlconf(None)
    75                 # Obtain a default resolver. It's needed early for handling 404's.
    76                 resolver = urlresolvers.RegexURLResolver(r'^/', None)
     73                # Setup default url resolver for this thread.
     74                urlconf = settings.ROOT_URLCONF
     75                urlresolvers.set_urlconf(urlconf)
     76                resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
    7777
    7878                # Apply request middleware
    7979                for middleware_method in self._request_middleware:
     
    8181                    if response:
    8282                        return response
    8383
    84                 # Get urlconf from request object, if available.  Otherwise use default.
    85                 urlconf = getattr(request, "urlconf", settings.ROOT_URLCONF)
    86                 # Set the urlconf for this thread to the one specified above.
    87                 urlresolvers.set_urlconf(urlconf)
    88                 # Reset the resolver with a possibly new urlconf
    89                 resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
     84                if hasattr(request, "urlconf"):
     85                    # Reset url resolver with a custom urlconf.
     86                    urlconf = request.urlconf
     87                    urlresolvers.set_urlconf(urlconf)
     88                    resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
    9089
    9190                callback, callback_args, callback_kwargs = resolver.resolve(
    9291                        request.path_info)
Back to Top