[Python-modules-commits] [python-django-debug-toolbar] 02/08: Imported Upstream version 1.5
Andrew Starr-Bochicchio
asb at moszumanska.debian.org
Sat Aug 20 17:34:04 UTC 2016
This is an automated email from the git hooks/post-receive script.
asb pushed a commit to branch master
in repository python-django-debug-toolbar.
commit 6e230f0274b58d46949a577ffebe2b6c94998834
Author: Andrew Starr-Bochicchio <a.starr.b at gmail.com>
Date: Sat Aug 20 12:01:43 2016 -0400
Imported Upstream version 1.5
---
.gitignore | 1 +
.travis.yml | 20 +--
Makefile | 6 +
README.rst | 5 +-
debug_toolbar/apps.py | 2 +-
debug_toolbar/compat.py | 54 ------
debug_toolbar/middleware.py | 17 +-
debug_toolbar/panels/__init__.py | 2 +-
debug_toolbar/panels/cache.py | 2 +-
debug_toolbar/panels/profiling.py | 2 +-
debug_toolbar/panels/sql/panel.py | 8 +-
debug_toolbar/panels/sql/tracking.py | 8 +-
debug_toolbar/panels/sql/utils.py | 2 +-
debug_toolbar/panels/templates/panel.py | 90 ++++------
debug_toolbar/panels/templates/views.py | 5 +-
debug_toolbar/settings.py | 195 +++++++++++----------
debug_toolbar/static/debug_toolbar/css/toolbar.css | 12 +-
.../static/debug_toolbar/js/jquery_post.js | 5 +-
.../static/debug_toolbar/js/jquery_pre.js | 6 +-
debug_toolbar/static/debug_toolbar/js/toolbar.js | 18 +-
.../static/debug_toolbar/js/toolbar.timer.js | 12 +-
debug_toolbar/templates/debug_toolbar/base.html | 6 +-
.../templates/debug_toolbar/panels/cache.html | 2 +-
.../templates/debug_toolbar/panels/headers.html | 2 +-
.../templates/debug_toolbar/panels/logging.html | 2 +-
.../templates/debug_toolbar/panels/profiling.html | 2 +-
.../templates/debug_toolbar/panels/request.html | 12 +-
.../templates/debug_toolbar/panels/settings.html | 2 +-
.../templates/debug_toolbar/panels/signals.html | 2 +-
.../templates/debug_toolbar/panels/sql.html | 10 +-
.../debug_toolbar/panels/sql_explain.html | 2 +-
.../debug_toolbar/panels/sql_profile.html | 2 +-
.../templates/debug_toolbar/panels/sql_select.html | 2 +-
.../debug_toolbar/panels/staticfiles.html | 2 +-
.../templates/debug_toolbar/panels/templates.html | 4 +-
.../templates/debug_toolbar/panels/timer.html | 4 +-
.../templates/debug_toolbar/panels/versions.html | 2 +-
debug_toolbar/templatetags/debug_toolbar_compat.py | 13 --
debug_toolbar/toolbar.py | 4 +-
debug_toolbar/utils.py | 60 +++++--
docs/changes.rst | 19 +-
docs/conf.py | 4 +-
docs/installation.rst | 78 +++++----
docs/panels.rst | 18 ++
example/README.rst | 2 +-
example/settings.py | 13 +-
setup.py | 9 +-
tests/__init__.py | 6 +-
tests/panels/test_redirects.py | 9 +-
tests/panels/test_sql.py | 6 +-
tests/settings.py | 8 +
tests/test_integration.py | 15 +-
tox.ini | 16 +-
53 files changed, 411 insertions(+), 399 deletions(-)
diff --git a/.gitignore b/.gitignore
index a866e5d..07f47b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ docs/_build
example/db.sqlite3
htmlcov
.tox
+node_modules
diff --git a/.travis.yml b/.travis.yml
index f0c01f2..f6983bc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,25 +2,25 @@ language: python
sudo: false
python:
- "2.7"
- - "3.2"
- "3.3"
- "3.4"
- "3.5"
env:
- - DJANGO="Django>=1.7.0,<1.8.0"
- DJANGO="Django>=1.8.0,<1.9.0"
- - DJANGO="https://www.djangoproject.com/download/1.9a1/tarball/"
+ - DJANGO="Django>=1.9.0,<1.10.0"
+ - DJANGO="Django>=1.10a,<1.11.0"
matrix:
exclude:
- - python: "3.2"
- env: DJANGO="https://www.djangoproject.com/download/1.9a1/tarball/"
- python: "3.3"
- env: DJANGO="https://www.djangoproject.com/download/1.9a1/tarball/"
- - python: "3.5"
- env: DJANGO="Django>=1.7.0,<1.8.0"
+ env: DJANGO="Django>=1.9.0,<1.10.0"
+ - python: "3.3"
+ env: DJANGO="Django>=1.10a,<1.11.0"
- python: "3.5"
env: DJANGO="Django>=1.8.0,<1.9.0"
install:
+ - travis_retry pip install sqlparse
+ - travis_retry pip install --pre $DJANGO
- pip install -e .
- - travis_retry pip install $DJANGO django-discover-runner sqlparse
-script: make test
+script:
+ - make jshint
+ - make test
diff --git a/Makefile b/Makefile
index 30aa2cd..5e97cf0 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,12 @@ example:
DJANGO_SETTINGS_MODULE=example.settings \
django-admin runserver
+jshint: node_modules/jshint/bin/jshint
+ ./node_modules/jshint/bin/jshint debug_toolbar/static/debug_toolbar/js/*.js
+
+node_modules/jshint/bin/jshint:
+ npm install jshint --prefix .
+
test:
DJANGO_SETTINGS_MODULE=tests.settings \
django-admin test tests
diff --git a/README.rst b/README.rst
index 5332b8c..76bd273 100644
--- a/README.rst
+++ b/README.rst
@@ -19,10 +19,11 @@ Here's a screenshot of the toolbar in action:
In addition to the built-in panels, a number of third-party panels are
contributed by the community.
-The current version of the Debug Toolbar is 1.4. It works on Django ≥ 1.7.
+The current version of the Debug Toolbar is 1.5 (in development). It works
+on Django ≥ 1.8.
Documentation, including installation and configuration instructions, is
-available at http://django-debug-toolbar.readthedocs.org/.
+available at https://django-debug-toolbar.readthedocs.io/.
The Django Debug Toolbar is released under the BSD license, like Django
itself. If you like it, please consider contributing!
diff --git a/debug_toolbar/apps.py b/debug_toolbar/apps.py
index 1894a40..09c489f 100644
--- a/debug_toolbar/apps.py
+++ b/debug_toolbar/apps.py
@@ -11,6 +11,6 @@ class DebugToolbarConfig(AppConfig):
verbose_name = _("Debug Toolbar")
def ready(self):
- if dt_settings.PATCH_SETTINGS:
+ if dt_settings.get_patch_settings():
dt_settings.patch_all()
dt_settings.check_middleware()
diff --git a/debug_toolbar/compat.py b/debug_toolbar/compat.py
index a38232c..f220b05 100644
--- a/debug_toolbar/compat.py
+++ b/debug_toolbar/compat.py
@@ -5,61 +5,7 @@ In order to avoid circular references, nothing should be imported from
debug_toolbar.
"""
-from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured
-
try:
from django.template.base import linebreak_iter # NOQA
except ImportError: # Django < 1.9
from django.views.debug import linebreak_iter # NOQA
-
-try:
- from django.template.engine import Engine
-except ImportError: # Django < 1.8
- Engine = None
- from django.template.context import get_standard_processors # NOQA
- from django.template.loader import find_template_loader # NOQA
-
-
-def get_template_dirs():
- """Compatibility method to fetch the template directories."""
- if Engine:
- try:
- engine = Engine.get_default()
- except ImproperlyConfigured:
- template_dirs = []
- else:
- template_dirs = engine.dirs
- else: # Django < 1.8
- template_dirs = settings.TEMPLATE_DIRS
- return template_dirs
-
-
-def get_template_loaders():
- """Compatibility method to fetch the template loaders."""
- if Engine:
- try:
- engine = Engine.get_default()
- except ImproperlyConfigured:
- loaders = []
- else:
- loaders = engine.template_loaders
- else: # Django < 1.8
- loaders = [
- find_template_loader(loader_name)
- for loader_name in settings.TEMPLATE_LOADERS]
- return loaders
-
-
-def get_template_context_processors():
- """Compatibility method to fetch the template context processors."""
- if Engine:
- try:
- engine = Engine.get_default()
- except ImproperlyConfigured:
- context_processors = []
- else:
- context_processors = engine.template_context_processors
- else: # Django < 1.8
- context_processors = get_standard_processors()
- return context_processors
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index dfd7179..1fb3e27 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -16,8 +16,6 @@ from debug_toolbar import settings as dt_settings
from debug_toolbar.toolbar import DebugToolbar
_HTML_TYPES = ('text/html', 'application/xhtml+xml')
-# Handles python threading module bug - http://bugs.python.org/issue14308
-threading._DummyThread._Thread__stop = lambda x: 1
def show_toolbar(request):
@@ -43,7 +41,7 @@ class DebugToolbarMiddleware(object):
def __init__(self):
# If SHOW_TOOLBAR_CALLBACK is a string, which is the recommended
# setup, resolve it to the corresponding callable.
- func_or_path = dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK']
+ func_or_path = dt_settings.get_config()['SHOW_TOOLBAR_CALLBACK']
if isinstance(func_or_path, six.string_types):
self.show_toolbar = import_string(func_or_path)
else:
@@ -113,16 +111,9 @@ class DebugToolbarMiddleware(object):
# Insert the toolbar in the response.
content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)
- insert_before = dt_settings.CONFIG['INSERT_BEFORE']
- try: # Python >= 2.7
- pattern = re.escape(insert_before)
- bits = re.split(pattern, content, flags=re.IGNORECASE)
- except TypeError: # Python < 2.7
- pattern = '(.+?)(%s|$)' % re.escape(insert_before)
- matches = re.findall(pattern, content, flags=re.DOTALL | re.IGNORECASE)
- bits = [m[0] for m in matches if m[1] == insert_before]
- # When the body ends with a newline, there's two trailing groups.
- bits.append(''.join(m[0] for m in matches if m[1] == ''))
+ insert_before = dt_settings.get_config()['INSERT_BEFORE']
+ pattern = re.escape(insert_before)
+ bits = re.split(pattern, content, flags=re.IGNORECASE)
if len(bits) > 1:
# When the toolbar will be inserted for sure, generate the stats.
for panel in reversed(toolbar.enabled_panels):
diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py
index bf1f633..716177c 100644
--- a/debug_toolbar/panels/__init__.py
+++ b/debug_toolbar/panels/__init__.py
@@ -24,7 +24,7 @@ class Panel(object):
@property
def enabled(self):
# Check to see if settings has a default value for it
- disabled_panels = dt_settings.CONFIG['DISABLE_PANELS']
+ disabled_panels = dt_settings.get_config()['DISABLE_PANELS']
panel_path = get_name_from_obj(self)
# Some panels such as the SQLPanel and TemplatesPanel exist in a
# panel module, but can be disabled without panel in the path.
diff --git a/debug_toolbar/panels/cache.py b/debug_toolbar/panels/cache.py
index 1b9d881..a8de279 100644
--- a/debug_toolbar/panels/cache.py
+++ b/debug_toolbar/panels/cache.py
@@ -33,7 +33,7 @@ def send_signal(method):
value = method(self, *args, **kwargs)
t = time.time() - t
- if dt_settings.CONFIG['ENABLE_STACKTRACES']:
+ if dt_settings.get_config()['ENABLE_STACKTRACES']:
stacktrace = tidy_stacktrace(reversed(get_stack()))
else:
stacktrace = []
diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py
index ce5dbe3..370a58c 100644
--- a/debug_toolbar/panels/profiling.py
+++ b/debug_toolbar/panels/profiling.py
@@ -172,7 +172,7 @@ class ProfilingPanel(Panel):
func_list = []
self.add_node(func_list,
root,
- dt_settings.CONFIG['PROFILER_MAX_DEPTH'],
+ dt_settings.get_config()['PROFILER_MAX_DEPTH'],
root.stats[3] / 8)
self.record_stats({'func_list': func_list})
diff --git a/debug_toolbar/panels/sql/panel.py b/debug_toolbar/panels/sql/panel.py
index 556e72f..275ec96 100644
--- a/debug_toolbar/panels/sql/panel.py
+++ b/debug_toolbar/panels/sql/panel.py
@@ -211,9 +211,10 @@ class SQLPanel(Panel):
# Queries are duplicates only if there's as least 2 of them.
# Also, to hide queries, we need to give all the duplicate groups an id
+ query_colors = contrasting_color_generator()
query_duplicates = dict(
(alias, dict(
- (query, duplicate_count)
+ (query, (duplicate_count, next(query_colors)))
for query, duplicate_count in queries.items()
if duplicate_count >= 2
))
@@ -222,14 +223,15 @@ class SQLPanel(Panel):
for alias, query in self._queries:
try:
- duplicates_count = query_duplicates[alias][query["raw_sql"]]
+ duplicates_count, color = query_duplicates[alias][query["raw_sql"]]
query["duplicate_count"] = duplicates_count
+ query["duplicate_color"] = color
except KeyError:
pass
for alias, alias_info in self._databases.items():
try:
- alias_info["duplicate_count"] = sum(e for e in query_duplicates[alias].values())
+ alias_info["duplicate_count"] = sum(e[0] for e in query_duplicates[alias].values())
except KeyError:
pass
diff --git a/debug_toolbar/panels/sql/tracking.py b/debug_toolbar/panels/sql/tracking.py
index bc6ea39..de8c866 100644
--- a/debug_toolbar/panels/sql/tracking.py
+++ b/debug_toolbar/panels/sql/tracking.py
@@ -102,7 +102,7 @@ class NormalCursorWrapper(object):
finally:
stop_time = time()
duration = (stop_time - start_time) * 1000
- if dt_settings.CONFIG['ENABLE_STACKTRACES']:
+ if dt_settings.get_config()['ENABLE_STACKTRACES']:
stacktrace = tidy_stacktrace(reversed(get_stack()))
else:
stacktrace = []
@@ -129,7 +129,7 @@ class NormalCursorWrapper(object):
'stacktrace': stacktrace,
'start_time': start_time,
'stop_time': stop_time,
- 'is_slow': duration > dt_settings.CONFIG['SQL_WARNING_THRESHOLD'],
+ 'is_slow': duration > dt_settings.get_config()['SQL_WARNING_THRESHOLD'],
'is_select': sql.lower().strip().startswith('select'),
'template_info': template_info,
}
@@ -152,10 +152,10 @@ class NormalCursorWrapper(object):
# We keep `sql` to maintain backwards compatibility
self.logger.record(**params)
- def callproc(self, procname, params=()):
+ def callproc(self, procname, params=None):
return self._record(self.cursor.callproc, procname, params)
- def execute(self, sql, params=()):
+ def execute(self, sql, params=None):
return self._record(self.cursor.execute, sql, params)
def executemany(self, sql, param_list):
diff --git a/debug_toolbar/panels/sql/utils.py b/debug_toolbar/panels/sql/utils.py
index 3bd31e8..c0bd4f4 100644
--- a/debug_toolbar/panels/sql/utils.py
+++ b/debug_toolbar/panels/sql/utils.py
@@ -9,7 +9,7 @@ from sqlparse import tokens as T
class BoldKeywordFilter:
"""sqlparse filter to bold SQL keywords"""
- def process(self, stack, stream):
+ def process(self, stream):
"""Process the token stream"""
for token_type, value in stream:
is_keyword = token_type in T.Keyword
diff --git a/debug_toolbar/panels/templates/panel.py b/debug_toolbar/panels/templates/panel.py
index 76ce689..7d8a079 100644
--- a/debug_toolbar/panels/templates/panel.py
+++ b/debug_toolbar/panels/templates/panel.py
@@ -5,20 +5,16 @@ from contextlib import contextmanager
from os.path import normpath
from pprint import pformat
-import django
from django import http
from django.conf.urls import url
from django.db.models.query import QuerySet, RawQuerySet
-from django.template import Context, RequestContext, Template
+from django.template import RequestContext, Template
from django.test.signals import template_rendered
from django.test.utils import instrumented_test_render
from django.utils import six
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
-from debug_toolbar.compat import (
- get_template_context_processors, get_template_dirs,
-)
from debug_toolbar.panels import Panel
from debug_toolbar.panels.sql.tracking import SQLQueryTriggered, recording
from debug_toolbar.panels.templates import views
@@ -37,58 +33,32 @@ if Template._render != instrumented_test_render:
# Monkey-patch to store items added by template context processors. The
# overhead is sufficiently small to justify enabling it unconditionally.
-if django.VERSION[:2] < (1, 8):
-
- def _request_context___init__(
- self, request, dict_=None, processors=None, current_app=None,
- use_l10n=None, use_tz=None):
- Context.__init__(
- self, dict_, current_app=current_app,
- use_l10n=use_l10n, use_tz=use_tz)
- if processors is None:
- processors = ()
- else:
- processors = tuple(processors)
- self.context_processors = OrderedDict()
- updates = dict()
- std_processors = get_template_context_processors()
- for processor in std_processors + processors:
- name = '%s.%s' % (processor.__module__, processor.__name__)
- context = processor(request)
- self.context_processors[name] = context
- updates.update(context)
- self.update(updates)
-
- RequestContext.__init__ = _request_context___init__
-
-else:
-
- @contextmanager
- def _request_context_bind_template(self, template):
- if self.template is not None:
- raise RuntimeError("Context is already bound to a template")
-
- self.template = template
- # Set context processors according to the template engine's settings.
- processors = (template.engine.template_context_processors +
- self._processors)
- self.context_processors = OrderedDict()
- updates = {}
- for processor in processors:
- name = '%s.%s' % (processor.__module__, processor.__name__)
- context = processor(self.request)
- self.context_processors[name] = context
- updates.update(context)
- self.dicts[self._processors_index] = updates
-
- try:
- yield
- finally:
- self.template = None
- # Unset context processors.
- self.dicts[self._processors_index] = {}
-
- RequestContext.bind_template = _request_context_bind_template
+ at contextmanager
+def _request_context_bind_template(self, template):
+ if self.template is not None:
+ raise RuntimeError("Context is already bound to a template")
+
+ self.template = template
+ # Set context processors according to the template engine's settings.
+ processors = (template.engine.template_context_processors +
+ self._processors)
+ self.context_processors = OrderedDict()
+ updates = {}
+ for processor in processors:
+ name = '%s.%s' % (processor.__module__, processor.__name__)
+ context = processor(self.request)
+ self.context_processors[name] = context
+ updates.update(context)
+ self.dicts[self._processors_index] = updates
+
+ try:
+ yield
+ finally:
+ self.template = None
+ # Unset context processors.
+ self.dicts[self._processors_index] = {}
+
+RequestContext.bind_template = _request_context_bind_template
class TemplatesPanel(Panel):
@@ -199,13 +169,13 @@ class TemplatesPanel(Panel):
info['context'] = '\n'.join(context_list)
template_context.append(info)
- # Fetch context_processors from any template
+ # Fetch context_processors/template_dirs from any template
if self.templates:
context_processors = self.templates[0]['context_processors']
+ template_dirs = self.templates[0]['template'].engine.dirs
else:
context_processors = None
-
- template_dirs = get_template_dirs()
+ template_dirs = []
self.record_stats({
'templates': template_context,
diff --git a/debug_toolbar/panels/templates/views.py b/debug_toolbar/panels/templates/views.py
index eb3fcf8..db505d8 100644
--- a/debug_toolbar/panels/templates/views.py
+++ b/debug_toolbar/panels/templates/views.py
@@ -3,10 +3,9 @@ from __future__ import absolute_import, unicode_literals
from django.http import HttpResponseBadRequest
from django.shortcuts import render_to_response
from django.template import TemplateDoesNotExist
+from django.template.engine import Engine
from django.utils.safestring import mark_safe
-from debug_toolbar.compat import get_template_loaders
-
def template_source(request):
"""
@@ -18,7 +17,7 @@ def template_source(request):
return HttpResponseBadRequest('"template" key is required')
final_loaders = []
- loaders = get_template_loaders()
+ loaders = Engine.get_default().template_loaders
for loader in loaders:
if loader is not None:
diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py
index 0402b01..fdf0bbb 100644
--- a/debug_toolbar/settings.py
+++ b/debug_toolbar/settings.py
@@ -5,6 +5,7 @@ from importlib import import_module
from django.conf import settings
from django.utils import six
+from django.utils.lru_cache import lru_cache
from django.utils.module_loading import import_string
# Always import this module as follows:
@@ -39,32 +40,63 @@ CONFIG_DEFAULTS = {
'SQL_WARNING_THRESHOLD': 500, # milliseconds
}
-USER_CONFIG = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {})
-# Backward-compatibility for 1.0, remove in 2.0.
-_RENAMED_CONFIG = {
- 'RESULTS_STORE_SIZE': 'RESULTS_CACHE_SIZE',
- 'ROOT_TAG_ATTRS': 'ROOT_TAG_EXTRA_ATTRS',
- 'HIDDEN_STACKTRACE_MODULES': 'HIDE_IN_STACKTRACES'
-}
-for old_name, new_name in _RENAMED_CONFIG.items():
- if old_name in USER_CONFIG:
+
+ at lru_cache()
+def get_config():
+ USER_CONFIG = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {})
+
+ # Backward-compatibility for 1.0, remove in 2.0.
+ _RENAMED_CONFIG = {
+ 'RESULTS_STORE_SIZE': 'RESULTS_CACHE_SIZE',
+ 'ROOT_TAG_ATTRS': 'ROOT_TAG_EXTRA_ATTRS',
+ 'HIDDEN_STACKTRACE_MODULES': 'HIDE_IN_STACKTRACES'
+ }
+ for old_name, new_name in _RENAMED_CONFIG.items():
+ if old_name in USER_CONFIG:
+ warnings.warn(
+ "%r was renamed to %r. Update your DEBUG_TOOLBAR_CONFIG "
+ "setting." % (old_name, new_name), DeprecationWarning)
+ USER_CONFIG[new_name] = USER_CONFIG.pop(old_name)
+
+ if 'HIDE_DJANGO_SQL' in USER_CONFIG:
+ warnings.warn(
+ "HIDE_DJANGO_SQL was removed. Update your "
+ "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
+ USER_CONFIG.pop('HIDE_DJANGO_SQL')
+
+ if 'TAG' in USER_CONFIG:
warnings.warn(
- "%r was renamed to %r. Update your DEBUG_TOOLBAR_CONFIG "
- "setting." % (old_name, new_name), DeprecationWarning)
- USER_CONFIG[new_name] = USER_CONFIG.pop(old_name)
-if 'HIDE_DJANGO_SQL' in USER_CONFIG:
- warnings.warn(
- "HIDE_DJANGO_SQL was removed. Update your "
- "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
- USER_CONFIG.pop('HIDE_DJANGO_SQL')
-if 'TAG' in USER_CONFIG:
- warnings.warn(
- "TAG was replaced by INSERT_BEFORE. Update your "
- "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
- USER_CONFIG['INSERT_BEFORE'] = '</%s>' % USER_CONFIG.pop('TAG')
-
-CONFIG = CONFIG_DEFAULTS.copy()
-CONFIG.update(USER_CONFIG)
+ "TAG was replaced by INSERT_BEFORE. Update your "
+ "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
+ USER_CONFIG['INSERT_BEFORE'] = '</%s>' % USER_CONFIG.pop('TAG')
+
+ CONFIG = CONFIG_DEFAULTS.copy()
+ CONFIG.update(USER_CONFIG)
+
+ if 'INTERCEPT_REDIRECTS' in USER_CONFIG:
+ warnings.warn(
+ "INTERCEPT_REDIRECTS is deprecated. Please use the "
+ "DISABLE_PANELS config in the "
+ "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
+ if USER_CONFIG['INTERCEPT_REDIRECTS']:
+ if 'debug_toolbar.panels.redirects.RedirectsPanel' \
+ in CONFIG['DISABLE_PANELS']:
+ # RedirectsPanel should be enabled
+ try:
+ CONFIG['DISABLE_PANELS'].remove(
+ 'debug_toolbar.panels.redirects.RedirectsPanel'
+ )
+ except KeyError:
+ # We wanted to remove it, but it didn't exist. This is fine
+ pass
+ elif 'debug_toolbar.panels.redirects.RedirectsPanel' \
+ not in CONFIG['DISABLE_PANELS']:
+ # RedirectsPanel should be disabled
+ CONFIG['DISABLE_PANELS'].add(
+ 'debug_toolbar.panels.redirects.RedirectsPanel'
+ )
+
+ return CONFIG
PANELS_DEFAULTS = [
@@ -82,71 +114,54 @@ PANELS_DEFAULTS = [
'debug_toolbar.panels.redirects.RedirectsPanel',
]
-try:
- PANELS = list(settings.DEBUG_TOOLBAR_PANELS)
-except AttributeError:
- PANELS = PANELS_DEFAULTS
-else:
- # Backward-compatibility for 1.0, remove in 2.0.
- _RENAMED_PANELS = {
- 'debug_toolbar.panels.version.VersionDebugPanel':
- 'debug_toolbar.panels.versions.VersionsPanel',
- 'debug_toolbar.panels.timer.TimerDebugPanel':
- 'debug_toolbar.panels.timer.TimerPanel',
- 'debug_toolbar.panels.settings_vars.SettingsDebugPanel':
- 'debug_toolbar.panels.settings.SettingsPanel',
- 'debug_toolbar.panels.headers.HeaderDebugPanel':
- 'debug_toolbar.panels.headers.HeadersPanel',
- 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel':
- 'debug_toolbar.panels.request.RequestPanel',
- 'debug_toolbar.panels.sql.SQLDebugPanel':
- 'debug_toolbar.panels.sql.SQLPanel',
- 'debug_toolbar.panels.template.TemplateDebugPanel':
- 'debug_toolbar.panels.templates.TemplatesPanel',
- 'debug_toolbar.panels.cache.CacheDebugPanel':
- 'debug_toolbar.panels.cache.CachePanel',
- 'debug_toolbar.panels.signals.SignalDebugPanel':
- 'debug_toolbar.panels.signals.SignalsPanel',
- 'debug_toolbar.panels.logger.LoggingDebugPanel':
- 'debug_toolbar.panels.logging.LoggingPanel',
- 'debug_toolbar.panels.redirects.InterceptRedirectsDebugPanel':
- 'debug_toolbar.panels.redirects.RedirectsPanel',
- 'debug_toolbar.panels.profiling.ProfilingDebugPanel':
- 'debug_toolbar.panels.profiling.ProfilingPanel',
- }
- for index, old_panel in enumerate(PANELS):
- new_panel = _RENAMED_PANELS.get(old_panel)
- if new_panel is not None:
- warnings.warn(
- "%r was renamed to %r. Update your DEBUG_TOOLBAR_PANELS "
- "setting." % (old_panel, new_panel), DeprecationWarning)
- PANELS[index] = new_panel
-
-
-if 'INTERCEPT_REDIRECTS' in USER_CONFIG:
- warnings.warn(
- "INTERCEPT_REDIRECTS is deprecated. Please use the "
- "DISABLE_PANELS config in the "
- "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)
- if USER_CONFIG['INTERCEPT_REDIRECTS']:
- if 'debug_toolbar.panels.redirects.RedirectsPanel' \
- in CONFIG['DISABLE_PANELS']:
- # RedirectsPanel should be enabled
- try:
- CONFIG['DISABLE_PANELS'].remove(
- 'debug_toolbar.panels.redirects.RedirectsPanel'
- )
- except KeyError:
- # We wanted to remove it, but it didn't exist. This is fine
- pass
- elif 'debug_toolbar.panels.redirects.RedirectsPanel' \
- not in CONFIG['DISABLE_PANELS']:
- # RedirectsPanel should be disabled
- CONFIG['DISABLE_PANELS'].add(
- 'debug_toolbar.panels.redirects.RedirectsPanel'
- )
-
-PATCH_SETTINGS = getattr(settings, 'DEBUG_TOOLBAR_PATCH_SETTINGS', settings.DEBUG)
+
+ at lru_cache()
+def get_panels():
+ try:
+ PANELS = list(settings.DEBUG_TOOLBAR_PANELS)
+ except AttributeError:
+ PANELS = PANELS_DEFAULTS
+ else:
+ # Backward-compatibility for 1.0, remove in 2.0.
+ _RENAMED_PANELS = {
+ 'debug_toolbar.panels.version.VersionDebugPanel':
+ 'debug_toolbar.panels.versions.VersionsPanel',
+ 'debug_toolbar.panels.timer.TimerDebugPanel':
+ 'debug_toolbar.panels.timer.TimerPanel',
+ 'debug_toolbar.panels.settings_vars.SettingsDebugPanel':
+ 'debug_toolbar.panels.settings.SettingsPanel',
+ 'debug_toolbar.panels.headers.HeaderDebugPanel':
+ 'debug_toolbar.panels.headers.HeadersPanel',
+ 'debug_toolbar.panels.request_vars.RequestVarsDebugPanel':
+ 'debug_toolbar.panels.request.RequestPanel',
+ 'debug_toolbar.panels.sql.SQLDebugPanel':
+ 'debug_toolbar.panels.sql.SQLPanel',
+ 'debug_toolbar.panels.template.TemplateDebugPanel':
+ 'debug_toolbar.panels.templates.TemplatesPanel',
+ 'debug_toolbar.panels.cache.CacheDebugPanel':
+ 'debug_toolbar.panels.cache.CachePanel',
+ 'debug_toolbar.panels.signals.SignalDebugPanel':
+ 'debug_toolbar.panels.signals.SignalsPanel',
+ 'debug_toolbar.panels.logger.LoggingDebugPanel':
+ 'debug_toolbar.panels.logging.LoggingPanel',
+ 'debug_toolbar.panels.redirects.InterceptRedirectsDebugPanel':
+ 'debug_toolbar.panels.redirects.RedirectsPanel',
+ 'debug_toolbar.panels.profiling.ProfilingDebugPanel':
+ 'debug_toolbar.panels.profiling.ProfilingPanel',
+ }
+ for index, old_panel in enumerate(PANELS):
+ new_panel = _RENAMED_PANELS.get(old_panel)
+ if new_panel is not None:
+ warnings.warn(
+ "%r was renamed to %r. Update your DEBUG_TOOLBAR_PANELS "
+ "setting." % (old_panel, new_panel), DeprecationWarning)
+ PANELS[index] = new_panel
+ return PANELS
+
+
+ at lru_cache()
+def get_patch_settings():
+ return getattr(settings, 'DEBUG_TOOLBAR_PATCH_SETTINGS', settings.DEBUG)
# The following functions can monkey-patch settings automatically. Several
diff --git a/debug_toolbar/static/debug_toolbar/css/toolbar.css b/debug_toolbar/static/debug_toolbar/css/toolbar.css
index aab48c0..ba929ef 100644
--- a/debug_toolbar/static/debug_toolbar/css/toolbar.css
+++ b/debug_toolbar/static/debug_toolbar/css/toolbar.css
@@ -38,13 +38,14 @@
font-family:sans-serif;
text-align:left;
text-shadow: none;
+ white-space: normal;
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
}
-#djDebug button {
+#djDebug button, #djDebug a.button {
background-color: #eee;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #eee), color-stop(100%, #cccccc));
background-image: -webkit-linear-gradient(top, #eee, #cccccc);
@@ -64,7 +65,7 @@
text-shadow: 0 1px 0 #eee;
}
-#djDebug button:hover {
+#djDebug button:hover, #djDebug a.button:hover {
background-color: #ddd;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ddd), color-stop(100%, #bbb));
background-image: -webkit-linear-gradient(top, #ddd, #bbb);
@@ -78,7 +79,7 @@
text-shadow: 0 1px 0 #ddd;
}
-#djDebug button:active {
+#djDebug button:active, #djDebug a.button:active {
border: 1px solid #aaa;
border-bottom: 1px solid #888;
-webkit-box-shadow: inset 0 0 5px 2px #aaa, 0 1px 0 0 #eee;
@@ -286,7 +287,7 @@
border-collapse:collapse;
width:100%;
background-color:#fff;
- display:block;
+ display:table;
margin-top:0.8em;
overflow: auto;
}
@@ -656,3 +657,6 @@
#djDebug .djdt-highlighted {
background-color: lightgrey;
}
+.djdt-hidden {
+ display: none;
+}
diff --git a/debug_toolbar/static/debug_toolbar/js/jquery_post.js b/debug_toolbar/static/debug_toolbar/js/jquery_post.js
index d94e675..9e4c8bc 100644
--- a/debug_toolbar/static/debug_toolbar/js/jquery_post.js
+++ b/debug_toolbar/static/debug_toolbar/js/jquery_post.js
@@ -1 +1,4 @@
-var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;
+var djdt = {jQuery: jQuery.noConflict(true)};
+if (window.define) {
+ window.define.amd = _djdt_define_amd_backup;
+}
diff --git a/debug_toolbar/static/debug_toolbar/js/jquery_pre.js b/debug_toolbar/static/debug_toolbar/js/jquery_pre.js
index d941996..cca2a0f 100644
--- a/debug_toolbar/static/debug_toolbar/js/jquery_pre.js
+++ b/debug_toolbar/static/debug_toolbar/js/jquery_pre.js
@@ -1 +1,5 @@
-var _djdt_define_backup = window.define; window.define = undefined;
+var _djdt_define_amd_backup;
+if (window.define) {
+ _djdt_define_amd_backup = window.define.amd;
+ window.define.amd = undefined;
+}
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js
index 3132d68..06aa42f 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js
@@ -64,16 +64,16 @@
if (name == 'button') {
var form = self.parents('form:eq(0)');
- ajax_data['url'] = self.attr('formaction');
+ ajax_data.url = self.attr('formaction');
if (form.length) {
- ajax_data['data'] = form.serialize();
- ajax_data['type'] = form.attr('method') || 'POST';
+ ajax_data.data = form.serialize();
+ ajax_data.type = form.attr('method') || 'POST';
}
}
if (name == 'a') {
- ajax_data['url'] = self.attr('href');
+ ajax_data.url = self.attr('href');
}
$.ajax(ajax_data).done(function(data){
@@ -141,13 +141,13 @@
// due to djdt.handleDragged being set to true.
if (djdt.handleDragged || event.pageY != startPageY) {
var top = baseY + event.clientY;
-
+
if (top < 0) {
top = 0;
} else if (top + handle.height() > windowHeight) {
top = windowHeight - handle.height();
}
-
+
handle.css({top: top});
djdt.handleDragged = true;
}
@@ -213,11 +213,13 @@
$('#djDebugToolbar li').removeClass('djdt-active');
// finally close toolbar
$('#djDebugToolbar').hide('fast');
- $('#djDebugToolbarHandle').show();
+ handle = $('#djDebugToolbarHandle')
+ handle.show();
// set handle position
var handleTop = djdt.cookie.get('djdttop');
if (handleTop) {
- $('#djDebugToolbarHandle').css({top: handleTop + 'px'});
+ handleTop = Math.min(handleTop, window.innerHeight - handle.outerHeight() - 10)
+ handle.css({top: handleTop + 'px'});
}
// Unbind keydown
$(document).unbind('keydown.djDebug');
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
index 0c0f4a5..b9bf3b4 100644
--- a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
@@ -23,16 +23,16 @@
var $row = $('<tr class="' + ((rowCount % 2) ? 'djDebugOdd' : 'djDebugEven') + '"></tr>');
if (endStat) {
// Render a start through end bar
- $row.html('<td>' + stat.replace('Start', '') + '</td>' +
- '<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong> </strong></div></div></td>' +
+ $row.html('<td>' + stat.replace('Start', '') + '</td>' +
+ '<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong> </strong></div></div></td>' +
'<td>' + (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ')</td>');
$row.find('strong').css({width: getCSSWidth(stat, endStat)});
} else {
// Render a point in time
- $row.html('<td>' + stat + '</td>' +
- '<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong> </strong></div></div></td>' +
- '<td>' + (perf.timing[stat] - timingOffset) + '</td>');
- $row.find('strong').css({width: 2});
+ $row.html('<td>' + stat + '</td>' +
+ '<td class="timeline"><div class="djDebugTimeline"><div class="djDebugLineChart"><strong> </strong></div></div></td>' +
+ '<td>' + (perf.timing[stat] - timingOffset) + '</td>');
+ $row.find('strong').css({width: 2});
}
$row.find('djDebugLineChart').css({left: getLeft(stat) + '%'});
$('#djDebugBrowserTimingTableBody').append($row);
diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html
index 30369f9..deaae80 100644
--- a/debug_toolbar/templates/debug_toolbar/base.html
+++ b/debug_toolbar/templates/debug_toolbar/base.html
@@ -10,10 +10,10 @@
<script src="{% static 'debug_toolbar/js/jquery_existing.js' %}"></script>
{% endif %}
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
-<div id="djDebug" hidden="hidden" dir="ltr"
+<div id="djDebug" class="djdt-hidden" dir="ltr"
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}>
- <div hidden="hidden" id="djDebugToolbar">
+ <div class="djdt-hidden" id="djDebugToolbar">
<ul id="djDebugPanelList">
{% if toolbar.panels %}
<li><a id="djHideToolBarButton" href="#" title="{% trans "Hide toolbar" %}">{% trans "Hide" %} »</a></li>
@@ -43,7 +43,7 @@
{% endfor %}
</ul>
</div>
- <div hidden="hidden" id="djDebugToolbarHandle">
+ <div class="djdt-hidden" id="djDebugToolbarHandle">
<span title="{% trans "Show toolbar" %}" id="djShowToolBarButton">«</span>
</div>
{% for panel in toolbar.panels %}
diff --git a/debug_toolbar/templates/debug_toolbar/panels/cache.html b/debug_toolbar/templates/debug_toolbar/panels/cache.html
index e541938..014e5f6 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/cache.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/cache.html
@@ -1,4 +1,4 @@
-{% load i18n %}{% load cycle from debug_toolbar_compat %}
+{% load i18n %}
<h4>{% trans "Summary" %}</h4>
<table>
<thead>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/headers.html b/debug_toolbar/templates/debug_toolbar/panels/headers.html
index a99e7d1..6b43e94 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/headers.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/headers.html
@@ -1,4 +1,4 @@
-{% load i18n %}{% load cycle from debug_toolbar_compat %}
+{% load i18n %}
<h4>{% trans "Request headers" %}</h4>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/logging.html b/debug_toolbar/templates/debug_toolbar/panels/logging.html
index 21d0c2e..3908f4f 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/logging.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/logging.html
@@ -1,4 +1,4 @@
-{% load i18n %}{% load cycle from debug_toolbar_compat %}
+{% load i18n %}
{% if records %}
<table>
<thead>
diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
index 7310016..1ac8ed1 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
@@ -12,7 +12,7 @@
</thead>
<tbody>
{% for call in func_list %}
- <tr class="djDebugProfileRow{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %}" depth="{{ call.depth }}">
+ <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %} djDebugProfileRow{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %}" depth="{{ call.depth }}">
<td>
<div data-padding-left="{{ call.indent }}px">
{% if call.has_subfuncs %}
diff --git a/debug_toolbar/templates/debug_toolbar/panels/request.html b/debug_toolbar/templates/debug_toolbar/panels/request.html
index c7d5ff9..c697237 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/request.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/request.html
@@ -1,4 +1,4 @@
-{% load i18n %}{% load cycle from debug_toolbar_compat %}
+{% load i18n %}
<h4>{% trans "View information" %}</h4>
<table>
@@ -11,11 +11,11 @@
</tr>
... 785 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-debug-toolbar.git
More information about the Python-modules-commits
mailing list