aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Leidel2012-04-04 21:27:27 +0200
committerJannis Leidel2012-04-04 21:27:27 +0200
commit3c791017fa316c4d672b2070a36218ba7acc78f1 (patch)
treed98365714ce926175791ba851440c635227b8ae8
parentd161058c9eb6a9ecb634084e6a4ed718afc45e28 (diff)
downloaddjango-debug-toolbar-3c791017fa316c4d672b2070a36218ba7acc78f1.tar.bz2
Moved loader into models module.
-rw-r--r--debug_toolbar/__init__.py4
-rw-r--r--debug_toolbar/models.py3
-rw-r--r--debug_toolbar/toolbar/loader.py27
3 files changed, 17 insertions, 17 deletions
diff --git a/debug_toolbar/__init__.py b/debug_toolbar/__init__.py
index d0bc5b8..48da4a6 100644
--- a/debug_toolbar/__init__.py
+++ b/debug_toolbar/__init__.py
@@ -5,7 +5,3 @@ try:
.get_distribution('django-debug-toolbar').version
except Exception, e:
VERSION = 'unknown'
-
-from debug_toolbar.toolbar.loader import load_panel_classes
-
-load_panel_classes()
diff --git a/debug_toolbar/models.py b/debug_toolbar/models.py
index e69de29..9ea9e86 100644
--- a/debug_toolbar/models.py
+++ b/debug_toolbar/models.py
@@ -0,0 +1,3 @@
+from debug_toolbar.toolbar.loader import load_panel_classes
+
+load_panel_classes()
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py
index b2b9b20..504f1b4 100644
--- a/debug_toolbar/toolbar/loader.py
+++ b/debug_toolbar/toolbar/loader.py
@@ -71,10 +71,10 @@ panel_classes = []
def load_panel_classes():
from django.conf import settings
- from django.core import exceptions
+ from django.core.exceptions import ImproperlyConfigured
- # Override this tuple by copying to settings.py as `DEBUG_TOOLBAR_PANELS`
- default_panels = (
+ # Check if settings has a DEBUG_TOOLBAR_PANELS, otherwise use default
+ panels = getattr(settings, 'DEBUG_TOOLBAR_PANELS', (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
@@ -82,26 +82,27 @@ def load_panel_classes():
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
- #'debug_toolbar.panels.cache.CacheDebugPanel',
+ # 'debug_toolbar.panels.cache.CacheDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
- )
- # Check if settings has a DEBUG_TOOLBAR_PANELS, otherwise use default
- if hasattr(settings, 'DEBUG_TOOLBAR_PANELS'):
- default_panels = settings.DEBUG_TOOLBAR_PANELS
-
- for panel_path in default_panels:
+ ))
+ for panel_path in panels:
try:
dot = panel_path.rindex('.')
except ValueError:
- raise exceptions.ImproperlyConfigured, '%s isn\'t a debug panel module' % panel_path
+ raise ImproperlyConfigured(
+ '%s isn\'t a debug panel module' % panel_path)
panel_module, panel_classname = panel_path[:dot], panel_path[dot + 1:]
try:
mod = __import__(panel_module, {}, {}, [''])
except ImportError, e:
- raise exceptions.ImproperlyConfigured, 'Error importing debug panel %s: "%s"' % (panel_module, e)
+ raise ImproperlyConfigured(
+ 'Error importing debug panel %s: "%s"' %
+ (panel_module, e))
try:
panel_class = getattr(mod, panel_classname)
except AttributeError:
- raise exceptions.ImproperlyConfigured, 'Toolbar Panel module "%s" does not define a "%s" class' % (panel_module, panel_classname)
+ raise ImproperlyConfigured(
+ 'Toolbar Panel module "%s" does not define a "%s" class' %
+ (panel_module, panel_classname))
panel_classes.append(panel_class)