From 1ca31fe54936d29f15cf23d92b9ab331e5199707 Mon Sep 17 00:00:00 2001 From: Chris Beaven Date: Tue, 29 Sep 2009 11:54:37 +1300 Subject: Template panel: Remove unnecessary large elements from each template context (request and sql_queries) Signed-off-by: Rob Hudson --- debug_toolbar/panels/template.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index 34a1897..cc3b1e1 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -1,6 +1,7 @@ from os.path import normpath from pprint import pformat +from django import http from django.conf import settings from django.core.signals import request_started from django.dispatch import Signal @@ -80,13 +81,24 @@ class TemplateDebugPanel(DebugPanel): if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('SHOW_TEMPLATE_CONTEXT', True): c = d.get('context', None) - d_list = [] - for _d in c.dicts: + context_list = [] + for context_layer in c.dicts: + for key, value in context_layer.items(): + # Replace any request elements - they have a large + # unicode representation. The request data is already + # made available from the Request Vars panel. + if isinstance(value, http.HttpRequest): + context_layer[key] = '' + # Remove the debugging sql_queries element from the + # context. The SQL data is already made available from + # the SQL panel. + elif key == 'sql_queries' and isinstance(value, list): + del context_layer[key] try: - d_list.append(pformat(_d)) + context_list.append(pformat(context_layer)) except UnicodeEncodeError: pass - info['context'] = '\n'.join(d_list) + info['context'] = '\n'.join(context_list) template_context.append(info) context = { 'templates': template_context, -- cgit v1.2.3