Skip to content

Commit fe3df82

Browse files
committed
Rename all panels consistently.
Enforce absolute imports to avoid clashing with built-in package names. Thanks Jannis for his feedback.
1 parent 7d24008 commit fe3df82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+226
-176
lines changed

debug_toolbar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33

44
__all__ = ['VERSION']

debug_toolbar/management/commands/debugsqlshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import print_function, unicode_literals
1+
from __future__ import absolute_import, print_function, unicode_literals
22

33
from time import time
44

debug_toolbar/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Debug Toolbar middleware
33
"""
44

5-
from __future__ import unicode_literals
5+
from __future__ import absolute_import, unicode_literals
66

77
import threading
88

debug_toolbar/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33
from django.conf import settings
44
from django.conf.urls import include, patterns, url

debug_toolbar/panels/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
2+
3+
import warnings
24

35
from django.template.defaultfilters import slugify
46
from django.template.loader import render_to_string
57

68

7-
class DebugPanel(object):
9+
class Panel(object):
810
"""
9-
Base class for debug panels.
11+
Base class for panels.
1012
"""
1113
# name = 'Base'
1214
# template = 'debug_toolbar/panels/base.html'
@@ -89,3 +91,11 @@ def process_view(self, request, view_func, view_args, view_kwargs):
8991

9092
def process_response(self, request, response):
9193
pass
94+
95+
96+
# Backward-compatibility for 1.0, remove in 2.0.
97+
class DebugPanel(Panel):
98+
99+
def __init__(self, *args, **kwargs):
100+
warnings.warn("DebugPanel was renamed to Panel.", DeprecationWarning)
101+
super(DebugPanel, self).__init__(*args, **kwargs)

debug_toolbar/panels/cache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33
import inspect
44
import sys
@@ -13,7 +13,7 @@
1313
from django.utils.datastructures import SortedDict
1414
from django.utils.translation import ugettext_lazy as _, ungettext
1515

16-
from debug_toolbar.panels import DebugPanel
16+
from debug_toolbar.panels import Panel
1717
from debug_toolbar.utils import (tidy_stacktrace, render_stacktrace,
1818
get_template_info, get_stack)
1919
from debug_toolbar import settings as dt_settings
@@ -127,7 +127,7 @@ def get_cache(*args, **kwargs):
127127
return CacheStatTracker(original_get_cache(*args, **kwargs))
128128

129129

130-
class CacheDebugPanel(DebugPanel):
130+
class CachePanel(Panel):
131131
"""
132132
Panel that displays the cache statistics.
133133
"""
@@ -136,7 +136,7 @@ class CacheDebugPanel(DebugPanel):
136136
has_content = True
137137

138138
def __init__(self, *args, **kwargs):
139-
super(CacheDebugPanel, self).__init__(*args, **kwargs)
139+
super(CachePanel, self).__init__(*args, **kwargs)
140140
self.total_time = 0
141141
self.hits = 0
142142
self.misses = 0

debug_toolbar/panels/headers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33
try:
44
from collections import OrderedDict
55
except ImportError:
66
from django.utils.datastructures import SortedDict as OrderedDict
77
from django.utils.translation import ugettext_lazy as _
8-
from debug_toolbar.panels import DebugPanel
8+
from debug_toolbar.panels import Panel
99

1010

11-
class HeaderDebugPanel(DebugPanel):
11+
class HeadersPanel(Panel):
1212
"""
1313
A panel to display HTTP headers.
1414
"""
15-
name = 'Header'
15+
name = 'Headers'
1616
template = 'debug_toolbar/panels/headers.html'
1717
has_content = True
1818
# List of environment variables we want to display
@@ -46,7 +46,7 @@ def process_request(self, request):
4646
self.request_headers = OrderedDict(
4747
(unmangle(k), v) for (k, v) in wsgi_env if k.startswith('HTTP_'))
4848
if 'Cookie' in self.request_headers:
49-
self.request_headers['Cookie'] = '=> see Request Vars panel'
49+
self.request_headers['Cookie'] = '=> see Request panel'
5050
self.environ = OrderedDict(
5151
(k, v) for (k, v) in wsgi_env if k in self.environ_filter)
5252
self.record_stats({

debug_toolbar/panels/logger.py renamed to debug_toolbar/panels/logging.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33
import datetime
44
import logging
@@ -7,7 +7,7 @@
77
except ImportError:
88
threading = None
99
from django.utils.translation import ungettext, ugettext_lazy as _
10-
from debug_toolbar.panels import DebugPanel
10+
from debug_toolbar.panels import Panel
1111

1212
MESSAGE_IF_STRING_REPRESENTATION_INVALID = '[Could not get log message]'
1313

@@ -104,9 +104,9 @@ def emit(self, record):
104104
logbook_handler.push_application() # register with logbook
105105

106106

107-
class LoggingPanel(DebugPanel):
107+
class LoggingPanel(Panel):
108108
name = 'Logging'
109-
template = 'debug_toolbar/panels/logger.html'
109+
template = 'debug_toolbar/panels/logging.html'
110110
has_content = True
111111

112112
def __init__(self, *args, **kwargs):

debug_toolbar/panels/profiling.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from __future__ import division, unicode_literals
1+
from __future__ import absolute_import, division, unicode_literals
22

33
from django.utils.translation import ugettext_lazy as _
44
from django.utils.safestring import mark_safe
55
from django.utils.six.moves import cStringIO
6-
from debug_toolbar.panels import DebugPanel
6+
from debug_toolbar.panels import Panel
77

88
try:
99
from line_profiler import LineProfiler, show_func
@@ -140,7 +140,7 @@ def line_stats_text(self):
140140
return self._line_stats_text
141141

142142

143-
class ProfilingDebugPanel(DebugPanel):
143+
class ProfilingPanel(Panel):
144144
"""
145145
Panel that displays profiling information.
146146
"""

debug_toolbar/panels/redirects.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from __future__ import unicode_literals
1+
from __future__ import absolute_import, unicode_literals
22

33
from django.core.handlers.wsgi import STATUS_CODE_TEXT
44
from django.shortcuts import render
55
from django.utils.translation import ugettext as _
66

7-
from debug_toolbar.panels import DebugPanel
7+
from debug_toolbar.panels import Panel
88

99

10-
class InterceptRedirectsPanel(DebugPanel):
10+
class RedirectsPanel(Panel):
1111
"""
1212
Panel that intercepts redirects and displays a page with debug info.
1313
"""

0 commit comments

Comments
 (0)