diff options
| author | Aymeric Augustin | 2013-11-24 12:27:37 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-11-24 12:27:37 +0100 | 
| commit | 6b0d32f7066cac5b6cb92e383eb486a3aa666d03 (patch) | |
| tree | dd95144a9e6272e798a7c03ef79f970b6fac7a6d | |
| parent | 1c1b4428642254f4e6b05e93bd135b894f708eeb (diff) | |
| download | django-debug-toolbar-6b0d32f7066cac5b6cb92e383eb486a3aa666d03.tar.bz2 | |
Fix cyclic import issues in db2de5b.
| -rw-r--r-- | debug_toolbar/middleware.py | 7 | ||||
| -rw-r--r-- | debug_toolbar/settings.py | 7 | 
2 files changed, 7 insertions, 7 deletions
| diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index b7114af..b58f588 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -8,6 +8,7 @@ import threading  from django.conf import settings  from django.utils.encoding import force_text +from django.utils.importlib import import_module  from debug_toolbar.toolbar import DebugToolbar  from debug_toolbar import settings as dt_settings @@ -38,7 +39,11 @@ class DebugToolbarMiddleware(object):      debug_toolbars = {}      def process_request(self, request): -        if not dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK'](request): +        func_path = dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK'] +        # Replace this with import_by_path in Django >= 1.6. +        mod_path, func_name = func_path.rsplit('.', 1) +        show_toolbar = getattr(import_module(mod_path), func_name) +        if not show_toolbar(request):              return          response = None          toolbar = DebugToolbar(request) diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 8534c2a..022fb8a 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -62,12 +62,7 @@ if 'TAG' in USER_CONFIG:  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: +if not isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types):      warnings.warn(          "SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your "          "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning) | 
