Middlewares Common

inyoka.middlewares.common

This module provides a middleware that sets the url conf for the current request depending on the site we are working on and does some more common stuff like session updating.

This middleware replaces the common middleware.

For development purposes we also set up virtual url dispatching modules for static and media.

copyright:
  1. 2007-2024 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

class inyoka.middlewares.common.CommonServicesMiddleware(get_response=None)

Hook in as first middleware for common tasks.

process_request(request)

Check for denied User-Agents and rewrite the URL based on settings.APPEND_SLASH and settings.PREPEND_WWW

process_response(request, response)

When the status code of the response is 404, it may redirect to a path with an appended slash if should_redirect_with_slash() returns True.

table_control_characters

Returns a translation table which removes all control characters not allowed in XML/HTML. Use it with str.translate.

The characters can be also described by the regex r’[-

-]’.

However, the regex performed slower in a little benchmark comparison.