From 12fdf7ea605d3716d6c9127e22a63bcc345d55be Mon Sep 17 00:00:00 2001
From: Jannis Leidel
Date: Sat, 7 Apr 2012 02:26:43 +0200
Subject: Updated cache panel to handle multiple backends and look more like
the SQL panel. This is based mostly on the awesome work by @diox done in
9aa062bb6c4318aa81c202003ea902249c0071d1. Closes #134.
---
debug_toolbar/utils/__init__.py | 15 +++++++++++++++
debug_toolbar/utils/tracking/db.py | 3 +--
2 files changed, 16 insertions(+), 2 deletions(-)
(limited to 'debug_toolbar/utils')
diff --git a/debug_toolbar/utils/__init__.py b/debug_toolbar/utils/__init__.py
index 01f817a..f7a3de0 100644
--- a/debug_toolbar/utils/__init__.py
+++ b/debug_toolbar/utils/__init__.py
@@ -6,6 +6,8 @@ import sys
from django.conf import settings
from django.views.debug import linebreak_iter
+from django.utils.html import escape
+from django.utils.safestring import mark_safe
# Figure out some paths
django_path = os.path.realpath(os.path.dirname(django.__file__))
@@ -48,6 +50,19 @@ def tidy_stacktrace(stack):
return trace
+def render_stacktrace(trace):
+ stacktrace = []
+ for frame in trace:
+ params = map(escape, frame[0].rsplit(os.path.sep, 1) + list(frame[1:]))
+ try:
+ stacktrace.append(u'{0}/{1} in {3}({2})\n {4}'.format(*params))
+ except IndexError:
+ # This frame doesn't have the expected format, so skip it and move on to the next one
+ continue
+ return mark_safe('\n'.join(stacktrace))
+
+
+
def get_template_info(source, context_lines=3):
line = 0
upto = 0
diff --git a/debug_toolbar/utils/tracking/db.py b/debug_toolbar/utils/tracking/db.py
index c0789eb..4d87090 100644
--- a/debug_toolbar/utils/tracking/db.py
+++ b/debug_toolbar/utils/tracking/db.py
@@ -91,8 +91,7 @@ class NormalCursorWrapper(object):
stop = datetime.now()
duration = ms_from_timedelta(stop - start)
enable_stacktraces = getattr(settings,
- 'DEBUG_TOOLBAR_CONFIG', {}) \
- .get('ENABLE_STACKTRACES', True)
+ 'DEBUG_TOOLBAR_CONFIG', {}).get('ENABLE_STACKTRACES', True)
if enable_stacktraces:
stacktrace = tidy_stacktrace(reversed(get_stack()))
else:
--
cgit v1.2.3