[Twisted-Python] Difficulty with twisted.web.client.getPage function
Alan Jern
alanjern at gmail.com
Sat Jun 4 23:47:07 EDT 2005
Hey, I'm new to Twisted and I've run into a problem that I can't solve.
I'm trying to write a simple Resource class that fetches a page from a
specified URL and returns it to the browser. I created a class called
MyResource in a .rpy file with the following two member functions:
def print_page (self, html):
self.rq.write(html)
self.rq.finish()
def render_GET (self, request):
self.rq = request
target = escape(request.args['target'][0])
getPage(target).addCallback(self.print_page)
return server.NOT_DONE_YET
When I run this script and send a request, the print_page function is
invoked but the variable 'html' has nothing in it. According to the
API and the examples I saw on the HOWTO section, this looks like it
ought to work. Clearly I'm missing something.
Any help would be greatly appreciated.
- Alan Jern
More information about the Twisted-Python
mailing list