API documentation for twod.wsgi

Enhanced WSGI support for Django applications.

class twod.wsgi.DjangoApplication

Bases: django.core.handlers.wsgi.WSGIHandler

Django request handler which uses our enhanced WSGI request class.

request_class

alias of TwodWSGIRequest

class twod.wsgi.TwodResponse(content='', mimetype=None, status=None, *args, **kwargs)

Bases: django.http.HttpResponse

Django-based response class which keeps the HTTP status reason phrase.

The original implementation in Django simply keeps the status code and does not allow developers to use custom HTTP status reason phrase, which is explicitly allowed by the HTTP specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

class twod.wsgi.handler.TwodWSGIRequest(environ)

Bases: django.core.handlers.wsgi.WSGIRequest, webob.request.Request

Pythonic proxy for the WSGI environment.

This class is the Django request extended by WebOb’s request. Where they both have the same members, Django’s take precedence. For example, .GET uses django.core.handlers.wsgi.WSGIRequest.GET instead of webob.Request.GET.

To access WebOb’s GET and POST dictionaries, you have to use .uGET and .uPOST respectively.

Embedded applications

twod.wsgi.make_wsgi_view(wsgi_app)

Return a callable which can be used as a Django view powered by the wsgi_app.

Parameters:wsgi_app – The WSGI which will run the view.
Returns:The view callable.
twod.wsgi.call_wsgi_app(wsgi_app, request, path_info)

Call the wsgi_app with request and return its response.

Parameters:
Raises twod.wsgi.exc.ApplicationCallError:
 

If path_info is not the last portion of the PATH_INFO in request.

Returns:

The response from the WSGI application, turned into a Django response.

Return type:

twod.wsgi.TwodResponse

Media serving

twod.wsgi.factories.add_media_to_app(django_app)

Return a WSGI application made up of the Django application, its media and the Django Admin media.

Exceptions

Exceptions raised by twod.wsgi.

exception twod.wsgi.exc.ApplicationCallError

Bases: twod.wsgi.exc.TwodWSGIException

Exception raised when an embedded WSGI application was not called properly.

exception twod.wsgi.exc.TwodWSGIException

Bases: exceptions.Exception

Base class for exceptions raised by twod.wsgi.