From db2de5b85ac1ae099b91bae402d21d6ea36ef306 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 24 Nov 2013 12:00:24 +0100 Subject: Make SHOW_TOOLBAR_CALLBACK a dotted path. Fix #473. --- debug_toolbar/settings.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'debug_toolbar/settings.py') diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 5a58b6b..8534c2a 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -20,7 +20,7 @@ CONFIG_DEFAULTS = { 'RESULTS_STORE_SIZE': 10, 'ROOT_TAG_EXTRA_ATTRS': '', 'SHOW_COLLAPSED': False, - 'SHOW_TOOLBAR_CALLBACK': None, + 'SHOW_TOOLBAR_CALLBACK': 'debug_toolbar.middleware.show_toolbar', # Panel options 'EXTRA_SIGNALS': [], 'ENABLE_STACKTRACES': True, @@ -36,7 +36,6 @@ CONFIG_DEFAULTS = { 'SQL_WARNING_THRESHOLD': 500, # milliseconds } -CONFIG = CONFIG_DEFAULTS.copy() USER_CONFIG = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}) # Backward-compatibility for 1.0, remove in 2.0. _RENAMED_CONFIG = { @@ -60,7 +59,18 @@ if 'TAG' in USER_CONFIG: "TAG was replaced by INSERT_BEFORE. Update your " "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning) USER_CONFIG['INSERT_BEFORE'] = '' % USER_CONFIG.pop('TAG') + +CONFIG = CONFIG_DEFAULTS.copy() CONFIG.update(USER_CONFIG) +if isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types): + # Replace this with import_by_path in Django >= 1.6. + mod_path, func_name = CONFIG['SHOW_TOOLBAR_CALLBACK'].rsplit('.', 1) + mod = import_module(mod_path) + CONFIG['SHOW_TOOLBAR_CALLBACK'] = getattr(mod, func_name) +else: + warnings.warn( + "SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your " + "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning) PANELS_DEFAULTS = [ -- cgit v1.2.3