From cc08c0d19bd5d1c7ff2281e3c3e4d92fa932e6d5 Mon Sep 17 00:00:00 2001 From: tschilling Date: Sat, 15 Feb 2014 08:59:20 -0500 Subject: Changing the collection to be fully qualified names and for it to be a set not a tuple. --- debug_toolbar/panels/__init__.py | 3 ++- debug_toolbar/settings.py | 23 +++++++++++++++-------- docs/configuration.rst | 6 +++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index e71d7b6..a7e3528 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -5,6 +5,7 @@ import warnings from django.template.loader import render_to_string from debug_toolbar import settings as dt_settings +from debug_toolbar.utils import get_name_from_obj class Panel(object): @@ -23,7 +24,7 @@ class Panel(object): @property def enabled(self): # Check to see if settings has a default value for it - if self.panel_id in dt_settings.CONFIG['DEFAULT_DISABLED_PANELS']: + if get_name_from_obj(self) in dt_settings.CONFIG['DEFAULT_DISABLED_PANELS']: default = 'off' else: default = 'on' diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 2d02aa5..0ea75ab 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -16,7 +16,7 @@ from django.utils import six CONFIG_DEFAULTS = { # Toolbar options - 'DEFAULT_DISABLED_PANELS': ('RedirectsPanel', ), + 'DEFAULT_DISABLED_PANELS': {'debug_toolbar.panels.redirects.RedirectsPanel'}, 'INSERT_BEFORE': '', 'RENDER_PANELS': None, 'RESULTS_STORE_SIZE': 10, @@ -131,15 +131,22 @@ if 'INTERCEPT_REDIRECTS' in USER_CONFIG: "DEFAULT_DISABLED_PANELS config in the" "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning) if USER_CONFIG['INTERCEPT_REDIRECTS']: - if 'RedirectsPanel' in CONFIG['DEFAULT_DISABLED_PANELS']: + if 'debug_toolbar.panels.redirects.RedirectsPanel' \ + in CONFIG['DEFAULT_DISABLED_PANELS']: # RedirectsPanel should be enabled - CONFIG['DEFAULT_DISABLED_PANELS'] = [ - panel for panel in CONFIG['DEFAULT_DISABLED_PANELS'] - if panel != "RedirectsPanel" - ] - elif not 'RedirectsPanel' in CONFIG['DEFAULT_DISABLED_PANELS']: + try: + CONFIG['DEFAULT_DISABLED_PANELS'].remove( + 'debug_toolbar.panels.redirects.RedirectsPanel' + ) + except KeyError: + # We wanted to remove it, but it didn't exist. This is fine + pass + elif not 'debug_toolbar.panels.redirects.RedirectsPanel' \ + in CONFIG['DEFAULT_DISABLED_PANELS']: # RedirectsPanel should be disabled - CONFIG['DEFAULT_DISABLED_PANELS'].append('RedirectsPanel') + CONFIG['DEFAULT_DISABLED_PANELS'].add( + 'debug_toolbar.panels.redirects.RedirectsPanel' + ) PATCH_SETTINGS = getattr(settings, 'DEBUG_TOOLBAR_PATCH_SETTINGS', settings.DEBUG) diff --git a/docs/configuration.rst b/docs/configuration.rst index 4cb94f0..972d9ac 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -59,10 +59,10 @@ Toolbar options * ``DEFAULT_DISABLED_PANELS`` - Default: ``('RedirectsPanel', )`` + Default: ``{'debug_toolbar.panels.redirects.RedirectsPanel'}`` - A collection of panel class names that are disabled (but still displayed) - by default. + This setting is a set of the full Python paths to each panel that you + want disabled (but still displayed) by default. * ``INSERT_BEFORE`` -- cgit v1.2.3