t.f.w.Resource(resource.Resource) : class documentation

Part of twisted.flow.web View Source View In Hierarchy

A resource which uses flow in its page generation.

Use it like this:
   from __future__ import generators
   from twisted.flow import flow

   def render(req):
       req.write("<html><head><title>Delayed</title></head>")
       req.write("<body><h1>Delayed WebPage</h1>")
       yield flow.Cooperate(5)
       req.write("<p>Delayed Content</p></body></html>")

   if __name__=='__main__':
       from twisted.internet import reactor
       from twisted.web.server import Site
       from twisted.flow.web import Resource
       print "visit http://localhost:8081/ to view"
       reactor.listenTCP(8081,Site(Resource(render)))
       reactor.run()
Method __init__ Initialize.
Method isLeaf Signal if this IResource implementor is a "leaf node" or not. If True, getChildWithDefault will not be called on this Resource.
Method render Render a given resource. See IResource's render method.

Inherited from Resource:

Method listStaticNames Undocumented
Method listStaticEntities Undocumented
Method listNames Undocumented
Method listEntities Undocumented
Method listDynamicNames Undocumented
Method listDynamicEntities Undocumented
Method getStaticEntity Undocumented
Method getDynamicEntity Undocumented
Method delEntity Undocumented
Method reallyPutEntity Undocumented
Method getChild Retrieve a 'child' resource from me.
Method getChildWithDefault Retrieve a static or dynamically generated child resource from me.
Method getChildForRequest Undocumented
Method putChild Register a static child.
Method render_HEAD Default handling of HEAD method.
def __init__(self, gen): (source)
Initialize.
def isLeaf(self): (source)
Signal if this IResource implementor is a "leaf node" or not. If True, getChildWithDefault will not be called on this Resource.
def render(self, req): (source)

Render a given resource. See IResource's render method.

I delegate to methods of self with the form 'render_METHOD' where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.

render_METHOD methods are expected to return a string which will be the rendered page, unless the return value is twisted.web.server.NOT_DONE_YET, in which case it is this class's responsibility to write the results to request.write(data), then call request.finish().

Old code that overrides render() directly is likewise expected to return a string or NOT_DONE_YET.
API Documentation for Twisted, generated by pydoctor at 2011-10-27 16:02:37.