Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.utils.ajax

This middleware was automatically being installed on every Lino site until 20240921. No longer used since then. See #5755 (Should we remove AjaxExceptionResponse?)

The idea was that 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 https://djangosnippets.org/snippets/650

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.

Classes

AjaxExceptionResponse(get_response)

The middleware class definition.

class lino.utils.ajax.AjaxExceptionResponse(get_response)

Bases: MiddlewareMixin

The middleware class definition.