diff options
| author | Jannis Leidel | 2012-04-07 02:26:43 +0200 |
|---|---|---|
| committer | Jannis Leidel | 2012-04-07 02:26:43 +0200 |
| commit | 12fdf7ea605d3716d6c9127e22a63bcc345d55be (patch) | |
| tree | 3d10c52bb303cfa79d158f9fb71e6f4d8f3facd1 /debug_toolbar/utils/__init__.py | |
| parent | cf2fcb55e297098922bb200eda33b77becfa0ea6 (diff) | |
| download | django-debug-toolbar-12fdf7ea605d3716d6c9127e22a63bcc345d55be.tar.bz2 | |
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.
Diffstat (limited to 'debug_toolbar/utils/__init__.py')
| -rw-r--r-- | debug_toolbar/utils/__init__.py | 15 |
1 files changed, 15 insertions, 0 deletions
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'<span class="path">{0}/</span><span class="file">{1}</span> in <span class="func">{3}</span>(<span class="lineno">{2}</span>)\n <span class="code">{4}</span>'.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 |
