From 405e56268a98dff64e500233094719092a61606b Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Mon, 18 Jan 2010 09:51:39 -0800 Subject: Ensure we honor request.urlconf. Previously, the debug toolbar would always bolt on URLs from ROOT_URLCONF, which would break another middleware if it inserts URLs onto request.urlconf. --- debug_toolbar/middleware.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'debug_toolbar/middleware.py') diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 5c10f9f..e9fd93e 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -33,8 +33,6 @@ class DebugToolbarMiddleware(object): """ def __init__(self): self.debug_toolbars = {} - self.original_urlconf = settings.ROOT_URLCONF - self.original_pattern = patterns('', ('', include(self.original_urlconf)),) self.override_url = True # Set method to use to decide to show toolbar @@ -59,7 +57,10 @@ class DebugToolbarMiddleware(object): def process_request(self, request): if self.show_toolbar(request): if self.override_url: - debug_toolbar.urls.urlpatterns += self.original_pattern + original_urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF) + debug_toolbar.urls.urlpatterns += patterns('', + ('', include(original_urlconf)), + ) self.override_url = False request.urlconf = 'debug_toolbar.urls' -- cgit v1.2.3