diff options
| author | Aymeric Augustin | 2013-11-10 10:10:28 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-10 16:02:49 +0100 |
| commit | f92aba225936fa768c098a8f1db51125ac1715ec (patch) | |
| tree | f853c2a91723157ad56b1765d03dcfbffd3e0b22 /debug_toolbar/panels/__init__.py | |
| parent | 6a8526a93b60ebae214dbe0d4cbf172c311802b9 (diff) | |
| download | django-debug-toolbar-f92aba225936fa768c098a8f1db51125ac1715ec.tar.bz2 | |
Disable instrumentation for disabled panels.
This eliminates the performance overhead when a panel is disabled.
Diffstat (limited to 'debug_toolbar/panels/__init__.py')
| -rw-r--r-- | debug_toolbar/panels/__init__.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index d4a61da..9586e80 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -22,31 +22,44 @@ class DebugPanel(object): context = {} # Panel methods + def __init__(self, toolbar, context={}): self.toolbar = toolbar self.context.update(context) self.slug = slugify(self.name) + def content(self): + if self.has_content: + context = self.context.copy() + context.update(self.get_stats()) + return render_to_string(self.template, context) + def dom_id(self): return 'djDebug%sPanel' % (self.name.replace(' ', '')) + # Titles and subtitles + def nav_title(self): - """Title showing in toolbar""" + """Title showing in sidebar""" raise NotImplementedError def nav_subtitle(self): - """Subtitle showing until title in toolbar""" + """Subtitle showing under title in sidebar""" return '' def title(self): """Title showing in panel""" raise NotImplementedError - def content(self): - if self.has_content: - context = self.context.copy() - context.update(self.get_stats()) - return render_to_string(self.template, context) + # Enable and disable (expensive) instrumentation + + def enable_instrumentation(self): + pass + + def disable_instrumentation(self): + pass + + # Store and retrieve stats (shared between panels) def record_stats(self, stats): panel_stats = self.toolbar.stats.get(self.slug) |
