diff options
| author | bkonkle | 2011-09-15 10:03:37 -0500 |
|---|---|---|
| committer | bkonkle | 2011-09-15 10:03:37 -0500 |
| commit | 78a8b4415163b8215d2a434a5dab4994871a4fc4 (patch) | |
| tree | d3d1f929d9949c95608ab39f00354d559e402d5a /debug_toolbar/toolbar/loader.py | |
| parent | 03cd2ded38bb6ccd3c97e11fcd1f99bd967dc996 (diff) | |
| download | django-debug-toolbar-78a8b4415163b8215d2a434a5dab4994871a4fc4.tar.bz2 | |
Added convenience methods to make it easier to work with panel stats
Diffstat (limited to 'debug_toolbar/toolbar/loader.py')
| -rw-r--r-- | debug_toolbar/toolbar/loader.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py index 3501c69..cf7a243 100644 --- a/debug_toolbar/toolbar/loader.py +++ b/debug_toolbar/toolbar/loader.py @@ -9,7 +9,7 @@ from django.utils.datastructures import SortedDict from django.utils.safestring import mark_safe class DebugToolbar(object): - + def __init__(self, request): self.request = request self._panels = SortedDict() @@ -38,25 +38,26 @@ class DebugToolbar(object): 'debug_toolbar.panels.logger.LoggingPanel', ) self.load_panels() + self.stats = {} def _get_panels(self): return self._panels.values() panels = property(_get_panels) - + def get_panel(self, cls): return self._panels[cls] - + def load_panels(self): """ Populate debug panels """ from django.conf import settings from django.core import exceptions - + # Check if settings has a DEBUG_TOOLBAR_PANELS, otherwise use default if hasattr(settings, 'DEBUG_TOOLBAR_PANELS'): self.default_panels = settings.DEBUG_TOOLBAR_PANELS - + for panel_path in self.default_panels: try: dot = panel_path.rindex('.') @@ -71,14 +72,14 @@ class DebugToolbar(object): 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) - + try: panel_instance = panel_class(context=self.template_context) except: raise # Bubble up problem loading panel - + self._panels[panel_class] = panel_instance - + def render_toolbar(self): """ Renders the overall Toolbar with panels inside. @@ -91,5 +92,5 @@ class DebugToolbar(object): 'js': mark_safe(open(os.path.join(media_path, 'js', 'toolbar.min.js'), 'r').read()), 'css': mark_safe(open(os.path.join(media_path, 'css', 'toolbar.min.css'), 'r').read()), }) - + return render_to_string('debug_toolbar/base.html', context) |
