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/panels/__init__.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/panels/__init__.py')
| -rw-r--r-- | debug_toolbar/panels/__init__.py | 35 | 
1 files changed, 22 insertions, 13 deletions
| diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index fa2e4b6..584ddb7 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -1,4 +1,6 @@ -"""Base DebugPanel class""" +from django.template.defaultfilters import slugify +from debug_toolbar.middleware import DebugToolbarMiddleware +  class DebugPanel(object):      """ @@ -6,43 +8,50 @@ class DebugPanel(object):      """      # name = Base      has_content = False # If content returns something, set to true in subclass - +          # We'll maintain a local context instance so we can expose our template      # context variables to panels which need them:      context = {} - +          # Panel methods      def __init__(self, context={}):          self.context.update(context) - +        self.toolbar = DebugToolbarMiddleware.get_current() +        self.slug = slugify(self.name) +          def dom_id(self):          return 'djDebug%sPanel' % (self.name.replace(' ', '')) - +          def nav_title(self):          """Title showing in toolbar"""          raise NotImplementedError - +          def nav_subtitle(self):          """Subtitle showing until title in toolbar"""          return '' - +          def title(self):          """Title showing in panel"""          raise NotImplementedError - +          def url(self):          raise NotImplementedError - +          def content(self):          raise NotImplementedError - +     +    def record_stats(self, stats): +        self.toolbar.stats[self.slug].update(stats) +     +    def get_stats(self): +        return self.toolbar.stats[self.slug] +          # Standard middleware methods      def process_request(self, request):          pass - +          def process_view(self, request, view_func, view_args, view_kwargs):          pass - +          def process_response(self, request, response):          pass - | 
