From 5701e1f21b4178da66dc017ac57ab91c06088bdf Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Fri, 8 Jan 2010 11:11:58 -0800 Subject: Print non-iterable template context layers as-is Signed-off-by: Rob Hudson --- debug_toolbar/panels/template.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index f6226c4..86b1c3e 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -83,19 +83,20 @@ class TemplateDebugPanel(DebugPanel): context_list = [] for context_layer in context_data.dicts: - for key, value in context_layer.items(): - # Replace any request elements - they have a large - # unicode representation and the request data is - # already made available from the Request Vars panel. - if isinstance(value, http.HttpRequest): - context_layer[key] = '<>' - # Replace the debugging sql_queries element. The SQL - # data is already made available from the SQL panel. - elif key == 'sql_queries' and isinstance(value, list): - context_layer[key] = '<>' - # Replace LANGUAGES, which is available in i18n context processor - elif key == 'LANGUAGES' and isinstance(value, tuple): - context_layer[key] = '<>' + if hasattr(context_layer, 'items'): + for key, value in context_layer.items(): + # Replace any request elements - they have a large + # unicode representation and the request data is + # already made available from the Request Vars panel. + if isinstance(value, http.HttpRequest): + context_layer[key] = '<>' + # Replace the debugging sql_queries element. The SQL + # data is already made available from the SQL panel. + elif key == 'sql_queries' and isinstance(value, list): + context_layer[key] = '<>' + # Replace LANGUAGES, which is available in i18n context processor + elif key == 'LANGUAGES' and isinstance(value, tuple): + context_layer[key] = '<>' try: context_list.append(pformat(context_layer)) except UnicodeEncodeError: -- cgit v1.2.3