On Tue, Dec 06, 2005 at 04:16:05AM +1000, A. Goryunov wrote:
> I might be just dumb, but I can't figure out the correct way to do what
> the following passage from Twisted.web's Howto suggests:
>
> "/Request a |Deferred|, return |server.NOT_DONE_YET|, and call
> |request.write("stuff")| and |request.finish()| later, in a callback on
> the |Deferred|/."
>
> How do I get at the request object from a callback function? All the
You can pass extra arguments to callback functions. So you can do e.g.:
d.addCallback(callbackFunc, request)
And then define callbackFunc as:
def callbackFunc(result, request):
...
Alternatively, as Grant suggests, you can use python's nested scopes to capture
the variable(s) you want.
-Andrew.
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web