From 5360a2ba9c5b866ce2502aa43606b2647acea63b Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 15 Dec 2013 13:06:16 +0100 Subject: Properly disable instrumentation for the template panel. It's important to disconnect the signal at the end of a request because the toolbar now stores panels for past request. Fix #491 (presumably). --- debug_toolbar/panels/templates/panel.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/panels/templates/panel.py b/debug_toolbar/panels/templates/panel.py index df39804..74f28b0 100644 --- a/debug_toolbar/panels/templates/panel.py +++ b/debug_toolbar/panels/templates/panel.py @@ -81,12 +81,8 @@ class TemplatesPanel(Panel): def __init__(self, *args, **kwargs): super(TemplatesPanel, self).__init__(*args, **kwargs) self.templates = [] - template_rendered.connect(self._store_template_info) def _store_template_info(self, sender, **kwargs): - if not self.enabled: - return - template, context = kwargs['template'], kwargs['context'] # Skip templates that we are generating through the debug toolbar. @@ -157,6 +153,12 @@ class TemplatesPanel(Panel): url(r'^template_source/$', 'template_source', name='template_source'), ) + def enable_instrumentation(self): + template_rendered.connect(self._store_template_info) + + def disable_instrumentation(self): + template_rendered.disconnect(self._store_template_info) + def process_response(self, request, response): template_context = [] for template_data in self.templates: -- cgit v1.2.3