This middleware is automatically being installed on every Lino site.

When an exception occurs during an AJAX call, Lino should not respond with Django's default HTML formatted error report but with a plain-text traceback because that's more readable when seen in a browser console.

Originally inspired by

Additions by LS:

  • also logs a warning on the development server because that is easier to read than opening firebug and look at the response.

  • must work also when DEBUG is False. Yes, on a production server it is not wise to publish the traceback, but our nice HTML formatted "Congratulations, you found a problem" page is never the right answer to an AJAX call.

  • format_request() adds information about the incoming call, including POST or PUT data.

(This module's source code is available here.)



The middleware class definition.

class lino.utils.ajax.AjaxExceptionResponse(get_response=None)

Bases: django.utils.deprecation.MiddlewareMixin

The middleware class definition.