From 52adaed63ed1d6255f66a0be7abb84dadcf457bb Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Fri, 23 Jan 2009 09:31:49 -0800 Subject: Fix triggering an extra SQL query via the auth context processor. Fixed by moving the template panel's context_processor introspection to the content method so this happens at the process_response time instead of at process_request time. Since context processors _were_ happening at the process_response end, it was triggering the query `user.get_and_delete_messages()` which was also getting triggered separately if used in templates (i.e. the admin templates) resulting in duplicate queries showing up in the toolbar. --- debug_toolbar/panels/template.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index fa85cb8..7dc7b06 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -48,11 +48,15 @@ class TemplateDebugPanel(DebugPanel): return '' def process_request(self, request): - self.context_processors = dict( - [("%s.%s" % (k.__module__, k.__name__), pformat(k(request))) for k in get_standard_processors()] - ) + self.request = request def content(self): + context_processors = dict( + [ + ("%s.%s" % (k.__module__, k.__name__), + pformat(k(self.request))) for k in get_standard_processors() + ] + ) template_context = [] for i, d in enumerate(self.templates): info = {} @@ -73,6 +77,6 @@ class TemplateDebugPanel(DebugPanel): context = { 'templates': template_context, 'template_dirs': [normpath(x) for x in settings.TEMPLATE_DIRS], - 'context_processors': self.context_processors, + 'context_processors': context_processors, } return render_to_string('debug_toolbar/panels/templates.html', context) -- cgit v1.2.3