From 886c19fc8aa98d43fe6e930da6d6e881e3ba3cfb Mon Sep 17 00:00:00 2001 From: Mark Unsworth Date: Fri, 19 Sep 2014 12:25:40 +0100 Subject: [PATCH] updated to use latest version of the debug-toolbar library. now inherits from Panel rather than the DebugPanel, replaced the content method with a template property and get_stats() method. --- debug_toolbar_mongo/operation_tracker.py | 2 ++ debug_toolbar_mongo/panel.py | 23 +++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/debug_toolbar_mongo/operation_tracker.py b/debug_toolbar_mongo/operation_tracker.py index 607dfa6..b4caa82 100644 --- a/debug_toolbar_mongo/operation_tracker.py +++ b/debug_toolbar_mongo/operation_tracker.py @@ -28,6 +28,8 @@ removes = [] WANT_STACK_TRACE = getattr(settings, 'DEBUG_TOOLBAR_MONGO_STACKTRACES', True) + + def _get_stacktrace(): if WANT_STACK_TRACE: try: diff --git a/debug_toolbar_mongo/panel.py b/debug_toolbar_mongo/panel.py index d5ae09c..a10197f 100644 --- a/debug_toolbar_mongo/panel.py +++ b/debug_toolbar_mongo/panel.py @@ -1,8 +1,7 @@ from django.template import Template, Context -from django.template.loader import render_to_string from django.utils.safestring import mark_safe -from debug_toolbar.panels import DebugPanel +from debug_toolbar.panels import Panel import operation_tracker @@ -16,11 +15,13 @@ {% endfor %} ''' -class MongoDebugPanel(DebugPanel): + +class MongoDebugPanel(Panel): """Panel that shows information about MongoDB operations. """ name = 'MongoDB' has_content = True + template = 'mongo-panel.html' def __init__(self, *args, **kwargs): super(MongoDebugPanel, self).__init__(*args, **kwargs) @@ -66,12 +67,14 @@ def title(self): def url(self): return '' - def content(self): - context = self.context.copy() - context['queries'] = operation_tracker.queries - context['inserts'] = operation_tracker.inserts - context['updates'] = operation_tracker.updates - context['removes'] = operation_tracker.removes - return render_to_string('mongo-panel.html', context) + def get_stats(self): + + return { + 'queries': operation_tracker.queries, + 'inserts': operation_tracker.inserts, + 'updates': operation_tracker.updates, + 'removes': operation_tracker.removes + } +