t.w.r.RenderMixin(object) : class documentation

Part of twisted.web2.resource View Source View In Hierarchy

Known subclasses: twisted.web2.resource.LeafResource, twisted.web2.resource.Resource, twisted.web2.static.StaticRenderMixin

Mix-in class for iweb.IResource which provides a dispatch mechanism for handling HTTP methods.
Method allowedMethods
Method checkPreconditions No summary
Method renderHTTP See iweb.IResource.renderHTTP.
Method http_OPTIONS Respond to a OPTIONS request. @param request: the request to process. @return: an object adaptable to iweb.IResponse.
Method http_TRACE Respond to a TRACE request. @param request: the request to process. @return: an object adaptable to iweb.IResponse.
Method http_HEAD Respond to a HEAD request. @param request: the request to process. @return: an object adaptable to iweb.IResponse.
Method http_GET Respond to a GET request.
Method render No summary
def allowedMethods(self): (source)
ReturnsA tuple of HTTP methods that are allowed to be invoked on this resource.
def checkPreconditions(self, request): (source)
Checks all preconditions imposed by this resource upon a request made against it.
Parametersrequestthe request to process.
ReturnsNone or a deferred whose callback value is request.
Raiseshttp.HTTPErrorif any precondition fails.
def renderHTTP(self, request): (source)

See iweb.IResource.renderHTTP.

This implementation will dispatch the given request to another method of self named http_METHOD, where METHOD is the HTTP method used by request (eg. http_GET, http_POST, etc.).

Generally, a subclass should implement those methods instead of overriding this one.

http_* methods are expected provide the same interface and return the same results as iweb.IResource.renderHTTP (and therefore this method).

etag and last-modified are added to the response returned by the http_* header, if known.

If an appropriate http_* method is not found, a responsecode.NOT_ALLOWED-status response is returned, with an appropriate allow header.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
def http_OPTIONS(self, request): (source)
Respond to a OPTIONS request.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
def http_TRACE(self, request): (source)
Respond to a TRACE request.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
def http_HEAD(self, request): (source)
Respond to a HEAD request.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
def http_GET(self, request): (source)

Respond to a GET request.

This implementation validates that the request body is empty and then dispatches the given request to render and returns its result.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
def render(self, request): (source)
Subclasses should implement this method to do page rendering. See http_GET.
Parametersrequestthe request to process.
Returnsan object adaptable to iweb.IResponse.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.