t.w.i.IResource(Interface) : interface documentation

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

Known implementations: twisted.plugins.twisted_web2._Web2ResourcePlugin, twisted.web2.auth.wrapper.HTTPAuthResource, twisted.web2.compat.OldNevowResourceAdapter, twisted.web2.resource.LeafResource, twisted.web2.resource.RedirectResource, twisted.web2.resource.Resource, twisted.web2.resource.WrapperResource, twisted.web2.static.File, twisted.web2.vhost.AutoVHostURIRewrite, twisted.web2.vhost.VHostURIRewrite, twisted.web2.wsgi.WSGIResource

An HTTP resource.

I serve 2 main purposes: one is to provide a standard representation for what HTTP specification calls an 'entity', and the other is to provide an mechanism for mapping URLs to content.
Method locateChild Locate another object which can be adapted to IResource.
Method renderHTTP Return an IResponse or a deferred which will fire an IResponse. This response will be written to the web browser which initiated the request.
def locateChild(req, segments): (source)
Locate another object which can be adapted to IResource.
Returns

A 2-tuple of (resource, remaining-path-segments), or a deferred which will fire the above.

Causes the object publishing machinery to continue on with specified resource and segments, calling the appropriate method on the specified resource.

If you return (self, server.StopTraversal), this instructs web2 to immediately stop the lookup stage, and switch to the rendering stage, leaving the remaining path alone for your render function to handle.
def renderHTTP(req): (source)
Return an IResponse or a deferred which will fire an IResponse. This response will be written to the web browser which initiated the request.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:22:34.