[Twisted-web] web2.server: returning a deferred from IResource.render()

ibu ibu at radempa.de
Thu Apr 12 14:35:57 CDT 2007


Hi,

I'm running web2.server (much like the example at
http://twistedmatrix.com/projects/web2/documentation/examples/intro/simple.py
) and everything works well, except if I return a deferred from an 
IResource.render() :

This does NOT work:
    def render(self, req):
            #...
            deferredResponse = h.getResponse() # generates a deferred
            return deferredResponse
While this DOES work:
    def render(self, req):
            #...
            deferredResponse = h.getResponse() # generates a deferred
            deferredResponse.callback(None)
            return deferredResponse.result

According to the docs (
http://twistedmatrix.com/projects/web2/documentation/howto/object-traversal.xhtml
) I should

    Return an IResponse or a deferred which will fire an
    IResponse.

What's wrong here?
Does anybody have a working exmaple?
To where does render() return its result?

My versions:
>>> twisted.__version__
'2.4.0'
>>> twisted.web2.__version__
'0.2.0'

>python -V
Python 2.4.4

I hope somebody can help.
Thx,
ibu



More information about the Twisted-web mailing list