Задать вопрос

Тел: +7 965 3737 888

578

Просмотров

6

Ответов

DebugFooter middleware

Adds a hidden footer to the bottom of every text/html page containing a list of SQL queries executed and templates that were loaded (including their full filesystem path to help debug complex template loading scenarios).

To use, drop in to a file called 'debug_middleware.py' on your Python path and add 'debug_middleware.DebugFooter' to your MIDDLEWARE_CLASSES setting.

Вопрос полезен? Да0/Нет0
file_4643.py(4.3Кб)
None

Ответы (6):

Ответaaron08544:27.09.2008
Ответ полезен? Да0/Нет0

If you don't care about the TextMate links, you can replace line 78: old: dispatcher.connect( self._storeRenderedTemplates, signal=template_rendered ) new: template_rendered.connect(self._storeRenderedTemplates)

and change the _storeRenderedTemplates function to

def _storeRenderedTemplates(self, **kwargs):
    #signal=signal, sender=sender, template=template, context=context):
    template = kwargs.get('template')
    if(template):
        self.templates_used.append(template)
    context = kwargs.get('context')
    if(context):
        self.contexts_used.append(context)

This is just a diff from 1033.

Ответpeterbe:03.09.2008
Ответ полезен? Да0/Нет0

This snippet has stopped working as of latest development version. Last line of the error is:

AttributeError: 'module' object has no attribute 'connect'

I can provide a full traceback if necessary. (I'm using mysql and revision 8922)

Ответcrucialfelix:07.07.2008
Ответ полезен? Да0/Нет0

excellent. is there anyway to also know what view was executed ?

Ответmixtline:23.05.2008
Ответ полезен? Да0/Нет0

  1. use "if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'" instead of "if request.is_ajax()"
  2. use

import re

p = re.compile('<\/body>', re.IGNORECASE)

response.content = p.sub(debug_content, force_unicode(content))

instead of line #128

Ответkayamb:21.05.2008
Ответ полезен? Да0/Нет0

Fantastic snippet! However, it does not work with ajax requests, so here's the changes I've done:

Ответmunhitsu:21.05.2008
Ответ полезен? Да0/Нет0

thanks - fantastic usability