Jump to >

djblets.extensions.middleware

Middleware for extensions.

class ExtensionsMiddleware(*args, **kwargs)[source]

Bases: django.utils.deprecation.MiddlewareMixin

Middleware to manage extension lifecycles and data.

__init__(*args, **kwargs)[source]

Initialize the middleware.

Parameters
  • *args (tuple) – Positional arguments to pass through to the superclass.

  • **kwargs (dict) – Keyword arguments to pass through to the superclass.

process_request(request)[source]
process_view(request, view, args, kwargs)[source]
class ExtensionsMiddlewareRunner(get_response=None)[source]

Bases: django.utils.deprecation.MiddlewareMixin

Middleware to execute middleware from extensions.

The process_*() methods iterate over all extensions’ middleware, calling the given method if it exists. The semantics of how Django executes each method are preserved.

This middleware should be loaded after the main extension middleware (djblets.extensions.middleware.ExtensionsMiddleware). It’s probably a good idea to have it be at the very end so that everything else in the core that needs to be initialized is done before any extension’s middleware is run.

process_view(request, view_func, view_args, view_kwargs)[source]

Process a view through extension middleware.

Parameters
  • request (django.http.HttpRequest) – The request object.

  • view_func (callable) – The view callable.

  • view_args (list) – Positional arguments to pass to the view.

  • view_kwargs (dict) – Keyword arguments to pass to the view.

Returns

Either a response object (in which case other middleware will not be run), or None.

Return type

django.http.HttpResponse or None

process_template_response(request, response)[source]

Process a template response through extension middleware.

Parameters
Returns

A new template response to execute.

Return type

django.template.response.TemplateResponse

process_exception(request, exception)[source]

Process an exception through extension middleware.

Parameters
Returns

Either a response object (in which case other middleware will not be run), or None.

Return type

django.http.HttpResponse or None

__call__(request)[source]

Run extension middleware.

Parameters

request (django.http.HttpRequest) – The HTTP request object.

Returns

The HTTP response.

Return type

django.http.HttpResponse

__annotations__ = {}