[Twisted-Python] using defferred?

Don Hiatt don at motorola.com
Wed Jul 9 14:17:53 MDT 2003


Howdy,

So I have a simple client that connects to "A" and sends
a requests and waits for a response. I'm using the clientfactory
and it works great. Now, I would like to integrate it with
a webserver, so when the user requests a certain url, I will
have my client connects to "A", send the request, wait for
the response, and then render the result in html and pass it
back to the user. The problem is, how do you do this in a 
event based system? I suspect Defferred might be my friend but 
I'm not sure.

My app looks like

class Simple(resource.Resource):
	isLeaf = True
	def render(self, request):
		sendRequest()
		... How do I wait for the client's datarecieved method
		.... to be called and then have access to the data??
		return result

....
__main__
m = Factory()
app.connect(h,p,m)

site = server.Site(Simple())
app.listenTCP(8888, site)


Thanks a lot for your time.

Cheers,

don





More information about the Twisted-Python mailing list