diff options
| author | Aymeric Augustin | 2013-11-24 10:42:43 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-11-24 11:01:44 +0100 | 
| commit | fe3df822111d3b56000deca354b0bceed7bde9cc (patch) | |
| tree | 8fe21689037cd975f83e7f70480b96e0ba2e3b6a /debug_toolbar/settings.py | |
| parent | 7d24008ac3d70796c1502215c665311d2f21d6fd (diff) | |
| download | django-debug-toolbar-fe3df822111d3b56000deca354b0bceed7bde9cc.tar.bz2 | |
Rename all panels consistently.
Enforce absolute imports to avoid clashing with built-in package names.
Thanks Jannis for his feedback.
Diffstat (limited to 'debug_toolbar/settings.py')
| -rw-r--r-- | debug_toolbar/settings.py | 72 | 
1 files changed, 56 insertions, 16 deletions
| diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index c86688a..7e23122 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -1,4 +1,6 @@ -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals + +import warnings  from django.conf import settings  from django.utils import six @@ -38,19 +40,57 @@ CONFIG.update(CONFIG_DEFAULTS)  CONFIG.update(getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {})) -PANELS_DEFAULTS = ( -    'debug_toolbar.panels.version.VersionDebugPanel', -    'debug_toolbar.panels.timer.TimerDebugPanel', -    'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel', -    'debug_toolbar.panels.headers.HeaderDebugPanel', -    'debug_toolbar.panels.request_vars.RequestVarsDebugPanel', -    'debug_toolbar.panels.sql.SQLDebugPanel', -    'debug_toolbar.panels.template.TemplateDebugPanel', -    'debug_toolbar.panels.cache.CacheDebugPanel', -    'debug_toolbar.panels.signals.SignalDebugPanel', -    'debug_toolbar.panels.logger.LoggingPanel', -    'debug_toolbar.panels.redirects.InterceptRedirectsPanel', -) - +PANELS_DEFAULTS = [ +    'debug_toolbar.panels.versions.VersionsPanel', +    'debug_toolbar.panels.timer.TimerPanel', +    'debug_toolbar.panels.settings.SettingsPanel', +    'debug_toolbar.panels.headers.HeadersPanel', +    'debug_toolbar.panels.request.RequestPanel', +    'debug_toolbar.panels.sql.SQLPanel', +    'debug_toolbar.panels.templates.TemplatesPanel', +    'debug_toolbar.panels.cache.CachePanel', +    'debug_toolbar.panels.signals.SignalsPanel', +    'debug_toolbar.panels.logging.LoggingPanel', +    'debug_toolbar.panels.redirects.RedirectsPanel', +    'debug_toolbar.panels.profiling.ProfilingPanel', +] -PANELS = getattr(settings, 'DEBUG_TOOLBAR_PANELS', PANELS_DEFAULTS) +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 | 
