aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/forms.py6
-rw-r--r--debug_toolbar/panels/logger.py9
-rw-r--r--debug_toolbar/panels/template.py3
-rw-r--r--debug_toolbar/templates/debug_toolbar/base.html6
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html6
-rw-r--r--debug_toolbar/utils/__init__.py6
-rw-r--r--debug_toolbar/utils/sql.py2
7 files changed, 22 insertions, 16 deletions
diff --git a/debug_toolbar/forms.py b/debug_toolbar/forms.py
index 60d339c..cc05f30 100644
--- a/debug_toolbar/forms.py
+++ b/debug_toolbar/forms.py
@@ -6,7 +6,7 @@ import hashlib
from django import forms
from django.conf import settings
from django.db import connections
-from django.utils.encoding import smart_bytes
+from django.utils.encoding import force_text
from django.utils.functional import cached_property
from django.core.exceptions import ValidationError
@@ -76,8 +76,8 @@ class SQLSelectForm(forms.Form):
return reformat_sql(self.cursor.db.ops.last_executed_query(self.cursor, sql, params))
def make_hash(self, data):
- params = settings.SECRET_KEY + data['sql'] + data['params']
- return hashlib.sha1(smart_bytes(params)).hexdigest()
+ params = force_text(settings.SECRET_KEY) + data['sql'] + data['params']
+ return hashlib.sha1(params.encode('utf-8')).hexdigest()
@property
def connection(self):
diff --git a/debug_toolbar/panels/logger.py b/debug_toolbar/panels/logger.py
index c6c1bd1..2c749ce 100644
--- a/debug_toolbar/panels/logger.py
+++ b/debug_toolbar/panels/logger.py
@@ -9,6 +9,8 @@ except ImportError:
from django.utils.translation import ungettext, ugettext_lazy as _
from debug_toolbar.panels import DebugPanel
+MESSAGE_IF_STRING_REPRESENTATION_INVALID = '[Could not get log message]'
+
class LogCollector(object):
def __init__(self):
@@ -49,8 +51,13 @@ class ThreadTrackingHandler(logging.Handler):
self.collector = collector
def emit(self, record):
+ try:
+ message = record.getMessage()
+ except Exception:
+ message = MESSAGE_IF_STRING_REPRESENTATION_INVALID
+
record = {
- 'message': record.getMessage(),
+ 'message': message,
'time': datetime.datetime.fromtimestamp(record.created),
'level': record.levelname,
'file': record.pathname,
diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py
index 8ecf5d6..f2f813c 100644
--- a/debug_toolbar/panels/template.py
+++ b/debug_toolbar/panels/template.py
@@ -7,6 +7,7 @@ from django import http
from django.conf import settings
from django.template.context import get_standard_processors
from django.test.signals import template_rendered
+from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
from django.db.models.query import QuerySet, RawQuerySet
from debug_toolbar.panels import DebugPanel
@@ -92,7 +93,7 @@ class TemplateDebugPanel(DebugPanel):
context_list.append(pformat(temp_layer))
except UnicodeEncodeError:
pass
- kwargs['context'] = context_list
+ kwargs['context'] = [force_text(item) for item in context_list]
self.templates.append(kwargs)
def nav_title(self):
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index a790bd1..7b42c84 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -2,13 +2,13 @@
<style type="text/css">
@media print { #djDebug {display:none;}}
</style>
-<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.min.css" type="text/css">
+<link rel="stylesheet" href="{{ STATIC_URL }}debug_toolbar/css/toolbar.min.css" type="text/css" />
<script type="text/javascript" src="{{ STATIC_URL }}debug_toolbar/js/toolbar.min.js"></script>
<div id="djDebug" style="display:none;" dir="ltr">
<div style="display:none;" id="djDebugToolbar">
<ul id="djDebugPanelList">
{% if panels %}
- <li><a id="djHideToolBarButton" href="#" title="{% trans "Hide Toolbar" %}">{% trans "Hide" %} &raquo;</a></li>
+ <li><a id="djHideToolBarButton" href="#" title="{% trans "Hide Toolbar" %}">{% trans "Hide" %} &#187;</a></li>
{% else %}
<li id="djDebugButton">DEBUG</li>
{% endif %}
@@ -33,7 +33,7 @@
</ul>
</div>
<div style="display:none;" id="djDebugToolbarHandle">
- <a title="{% trans "Show Toolbar" %}" id="djShowToolBarButton" href="#">&laquo;</a>
+ <a title="{% trans "Show Toolbar" %}" id="djShowToolBarButton" href="#">&#171;</a>
</div>
{% for panel in panels %}
{% if panel.has_content %}
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index 36201fc..064413c 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -4,7 +4,7 @@
<ul class="stats">
{% for alias, info in databases %}
<li>
- <strong class="label"><span style="background-color: rgb({{ info.rgb_color|join:", " }})" class="color">&nbsp;</span> {{ alias }}</strong>
+ <strong class="label"><span style="background-color: rgb({{ info.rgb_color|join:", " }})" class="color">&#160;</span> {{ alias }}</strong>
<span class="info">{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %})</span>
</li>
{% endfor %}
@@ -15,7 +15,7 @@
<table>
<thead>
<tr>
- <th class="color">&nbsp;</th>
+ <th class="color">&#160;</th>
<th class="query" colspan="2">{% trans 'Query' %}</th>
<th class="timeline">{% trans 'Timeline' %}</th>
<th class="time">{% trans 'Time (ms)' %}</th>
@@ -25,7 +25,7 @@
<tbody>
{% for query in queries %}
<tr class="djDebugHoverable {% cycle 'djDebugOdd' 'djDebugEven' %}{% if query.is_slow %} djDebugRowWarning{% endif %}{% if query.starts_trans %} djDebugStartTransaction{% endif %}{% if query.ends_trans %} djDebugEndTransaction{% endif %}{% if query.in_trans %} djDebugInTransaction{% endif %}" id="sqlMain_{{ forloop.counter }}">
- <td class="color"><span style="background-color: rgb({{ query.rgb_color|join:", " }});">&nbsp;</span></td>
+ <td class="color"><span style="background-color: rgb({{ query.rgb_color|join:", " }});">&#160;</span></td>
<td class="toggle">
<a class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}" data-toggle-open="+" data-toggle-close="-" href="javascript:void(0)">+</a>
</td>
diff --git a/debug_toolbar/utils/__init__.py b/debug_toolbar/utils/__init__.py
index 297c901..75f3024 100644
--- a/debug_toolbar/utils/__init__.py
+++ b/debug_toolbar/utils/__init__.py
@@ -7,6 +7,7 @@ import sys
from django.conf import settings
from django.views.debug import linebreak_iter
+from django.utils.encoding import force_text
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils import six
@@ -39,10 +40,7 @@ def tidy_stacktrace(stack):
continue
if socketserver_path in s_path:
continue
- if not text:
- text = ''
- else:
- text = (''.join(text)).strip()
+ text = (''.join(force_text(t) for t in text)).strip() if text else ''
trace.append((path, line_no, func_name, text))
return trace
diff --git a/debug_toolbar/utils/sql.py b/debug_toolbar/utils/sql.py
index 4e0d70d..2810699 100644
--- a/debug_toolbar/utils/sql.py
+++ b/debug_toolbar/utils/sql.py
@@ -29,5 +29,5 @@ def reformat_sql(sql):
def swap_fields(sql):
- return re.sub('SELECT</strong> (.*?) <strong>FROM', 'SELECT</strong> <a class="djDebugUncollapsed djDebugToggle" href="#">&bull;&bull;&bull;</a> ' +
+ return re.sub('SELECT</strong> (.*?) <strong>FROM', 'SELECT</strong> <a class="djDebugUncollapsed djDebugToggle" href="#">&#8226;&#8226;&#8226;</a> ' +
'<a class="djDebugCollapsed djDebugToggle" href="#">\g<1></a> <strong>FROM', sql)