Example #1
0
from debug_toolbar.panels import DebugPanel
from django.template.loader import render_to_string
from django.shortcuts import render_to_response
from django.utils import simplejson
from django.core.cache import cache

from debug_toolbar.stats import track, get_stats

# Track stats on these function calls
cache.set = track(cache.set, "cache")
cache.get = track(cache.get, "cache")
cache.delete = track(cache.delete, "cache")
cache.add = track(cache.add, "cache")
cache.get_many = track(cache.get_many, "cache")


class CacheDebugPanel(DebugPanel):
    """
    Panel that displays the cache statistics.
    """

    name = "Cache"

    def process_ajax(self, request):
        action = request.GET.get("op")
        if action == "explain":
            return render_to_response("debug_toolbar/panels/cache_explain.html")

    def title(self):
        return "Cache: %.2fms" % get_stats().get_total_time("cache")
from debug_toolbar.panels import DebugPanel
from django.conf import settings
from django.dispatch import dispatcher
from django.core.signals import request_started
from django.test.signals import template_rendered
from django.template.loader import render_to_string
from django.shortcuts import render_to_response
from django import template

from debug_toolbar.stats import track, get_stats

template.Template.render = track(template.Template.render, 'templates:django')

try:
    import jinja2
except ImportError:
    pass
else:
    jinja2.Environment.get_template = track(jinja2.Environment.get_template, 'templates:jinja2')

try:
    import jinja
except ImportError:
    pass
else:
    jinja.Environment.get_template = track(jinja.Environment.get_template, 'templates:jinja')

class TemplatesDebugPanel(DebugPanel):
    """
    Panel that displays information about the SQL queries run while processing the request.
    """
Example #3
0
from debug_toolbar.panels import DebugPanel
from django.template.loader import render_to_string
from django.shortcuts import render_to_response
from django.utils import simplejson
from django.core.cache import cache

from debug_toolbar.stats import track, get_stats

# Track stats on these function calls
cache.set = track(cache.set, 'cache')
cache.get = track(cache.get, 'cache')
cache.delete = track(cache.delete, 'cache')
cache.add = track(cache.add, 'cache')
cache.get_many = track(cache.get_many, 'cache')

class CacheDebugPanel(DebugPanel):
    """
    Panel that displays the cache statistics.
    """
    name = 'Cache'

    def process_ajax(self, request):
        action = request.GET.get('op')
        if action == 'explain':
            return render_to_response('debug_toolbar/panels/cache_explain.html')

    def title(self):
        return 'Cache: %.2fms' % get_stats().get_total_time('cache')

    def url(self):
        return ''