diff options
| author | Aymeric Augustin | 2013-11-09 19:05:27 +0100 |
|---|---|---|
| committer | Aymeric Augustin | 2013-11-10 10:39:42 +0100 |
| commit | 631bbd18c10f572e31ef30f4dc78df942beeffd4 (patch) | |
| tree | 39ba5916e0dcb66da58f6d1d86e25ed4b70c9e1c /debug_toolbar/panels | |
| parent | 0b4fc3e4c30a645e4d7a706d890c74a82c88cb8c (diff) | |
| download | django-debug-toolbar-631bbd18c10f572e31ef30f4dc78df942beeffd4.tar.bz2 | |
Avoid some implicit global lookups.
They made it impossible to preserve panel data after the end of a
request.
Diffstat (limited to 'debug_toolbar/panels')
| -rw-r--r-- | debug_toolbar/panels/__init__.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index 8be87e1..a48b1b3 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -18,7 +18,8 @@ class DebugPanel(object): context = {} # Panel methods - def __init__(self, context={}): + def __init__(self, toolbar, context={}): + self.toolbar = toolbar self.context.update(context) self.slug = slugify(self.name) @@ -44,16 +45,14 @@ class DebugPanel(object): return render_to_string(self.template, context) def record_stats(self, stats): - toolbar = DebugToolbarMiddleware.get_current() - panel_stats = toolbar.stats.get(self.slug) + panel_stats = self.toolbar.stats.get(self.slug) if panel_stats: panel_stats.update(stats) else: - toolbar.stats[self.slug] = stats + self.toolbar.stats[self.slug] = stats def get_stats(self): - toolbar = DebugToolbarMiddleware.get_current() - return toolbar.stats.get(self.slug, {}) + return self.toolbar.stats.get(self.slug, {}) # Standard middleware methods |
