Skip to content

Commit

Permalink
Add a default 'content' method, since the method is now identical on …
Browse files Browse the repository at this point in the history
…every panel
  • Loading branch information
bkonkle committed Sep 15, 2011
1 parent c20e83f commit ed9bca7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions debug_toolbar/panels/__init__.py
@@ -1,12 +1,14 @@
from django.template.defaultfilters import slugify
from django.template.loader import render_to_string
from debug_toolbar.middleware import DebugToolbarMiddleware


class DebugPanel(object):
"""
Base class for debug panels.
"""
# name = Base
# name = 'Base'
# template = 'debug_toolbar/panels/base.html'
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
Expand Down Expand Up @@ -38,7 +40,10 @@ def url(self):
raise NotImplementedError

def content(self):
raise NotImplementedError
if self.has_content:
context = self.context.copy()
context.update(self.get_stats())
return render_to_string(self.template, context)

def record_stats(self, stats):
panel_stats = self.toolbar.stats.get(self.slug)
Expand Down

0 comments on commit ed9bca7

Please sign in to comment.