aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar/toolbar/loader.py
diff options
context:
space:
mode:
authorChris Adams2010-01-14 08:02:49 -0800
committerRob Hudson2010-01-14 08:02:49 -0800
commit4baa51e0be674428a2314e08efe43628184bc42a (patch)
treed3584431a61ad1fbdf885e024950f472b89ff21e /debug_toolbar/toolbar/loader.py
parentfba93b813f90430545d5acaa25ef218f792360ab (diff)
downloaddjango-debug-toolbar-4baa51e0be674428a2314e08efe43628184bc42a.tar.bz2
Template panel context cleanup.
All panels get a copy of the template context when created and use an updated copy when rendering so they can have full access to context vars and avoid making changes to the shared context. Signed-off-by: Rob Hudson <rob@cogit8.org>
Diffstat (limited to 'debug_toolbar/toolbar/loader.py')
-rw-r--r--debug_toolbar/toolbar/loader.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/debug_toolbar/toolbar/loader.py b/debug_toolbar/toolbar/loader.py
index c7f999e..8e89aef 100644
--- a/debug_toolbar/toolbar/loader.py
+++ b/debug_toolbar/toolbar/loader.py
@@ -11,6 +11,9 @@ class DebugToolbar(object):
self.config = {
'INTERCEPT_REDIRECTS': True,
}
+ self.template_context = {
+ 'BASE_URL': self.request.META.get('SCRIPT_NAME', ''),
+ }
# Override this tuple by copying to settings.py as `DEBUG_TOOLBAR_PANELS`
self.default_panels = (
'debug_toolbar.panels.version.VersionDebugPanel',
@@ -56,9 +59,8 @@ class DebugToolbar(object):
raise exceptions.ImproperlyConfigured, 'Toolbar Panel module "%s" does not define a "%s" class' % (panel_module, panel_classname)
try:
- panel_instance = panel_class()
+ panel_instance = panel_class(context=self.template_context)
except:
- print panel_class
raise # Bubble up problem loading panel
self.panels.append(panel_instance)
@@ -67,7 +69,7 @@ class DebugToolbar(object):
"""
Renders the overall Toolbar with panels inside.
"""
- return render_to_string('debug_toolbar/base.html', {
- 'panels': self.panels,
- 'BASE_URL': self.request.META.get('SCRIPT_NAME', ''),
- })
+ context = self.template_context.copy()
+ context.update({ 'panels': self.panels, })
+
+ return render_to_string('debug_toolbar/base.html', context)