On Thu, 12 Apr 2007 21:35:57 +0200, ibu <[EMAIL PROTECTED]> wrote:
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 it may be the case that a program can only work in one particular
way (and so saying that a program works may fully describe its behavior),
it is not the case that a program can only be broken in one particular
way. Don't just say that something doesn't work. Explain the behavior
you expected to see and how the behavior you did see differed from that.
It's also very useful to include complete examples. In the above, I have
no idea what `h' is or what `h.getResponse' might return. This means I
really have no idea what the render method might even be trying to do, let
alone what it actually does.
While this DOES work:
def render(self, req):
#...
deferredResponse = h.getResponse() # generates a deferred
deferredResponse.callback(None)
return deferredResponse.result
The `result' attribute of Deferreds is not strictly public, and you should
avoid using it. The above is equivalent to returning f(None), where f is
the composite function of all of the callbacks on deferredResult, though
what those might be I do not know.
Jean-Paul
_______________________________________________
Twisted-web mailing list
[EMAIL PROTECTED]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web