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

Тел: +7 965 3737 888

565

Просмотров

7

Ответов

Simple Exception Response for AJAX debugging

When debugging AJAX with Firebug, if a response is 500, it is a pain to have to view the entire source of the pretty exception page. This is a simple middleware that just returns the exception without any markup. You can add this anywhere in your python path and then put it in you settings file. It will only unprettify your exceptions when there is a XMLHttpRequest header. Tested in FF2 with the YUI XHR. Comments welcome.

EDIT: I recently changed the request checking to use the is_ajax() method. This gives you access to these simple exceptions for get requests as well (even though you could just point your browser there).

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

Ответы (7):

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

Is it works with dev(trunk) of django?

I copy code to utils/middleware.py and add line to settings.py:

MIDDLEWARE_CLASSES = (
    ......
    'utils.middleware.AJAXSimpleExceptionResponse'
)

but I don't see any changes in ajax exceptions output..

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

I always detect in my Javascript if the response holds HTML. If it does, I create a floating iframe and pass it the response. That way you can fold/unfold the stack source and use the debug page as usual.

Simon.

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

I use it, too.

I use the Poster firefox add-on for a lot of Ajax-Debugging, but it seems buggy for HTTP_ACCEPT headers.

Thanks.

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

You can also document.write() on 500 in the javascript to display the error instead of trying to read it in firebug.

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

Works great. Thanks!

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

This will be great. Although I have gotten good at finding the exception in the source of the pretty error pages :)

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

Nice idea - thanks!