[Twisted-Python] Ticket 1009

Andrew Francis andrewfr_ice at yahoo.com
Tue Mar 17 13:44:30 EDT 2009


Hi Colleagues:

I guess I am making today "Look at Twisted Documentation Day." I am looking at ticket 1009.

For inline generator examples, here is the example I use in "Adventures in Stackless Python Twisted Integration." In turn, this example comes from the discussions in I believe January 2008 with JP Calerone.

I can modify the example (and perhaps add illustrations) to show situations where inline generators are handy.


"""
Example of using an inline generator to make a Twisted call from a
protocol handler
"""

class MyRequestHandler(http.Request):
    @defer.inlineCallbacks
    def process(self):
        try:
          result = \
          yield client.getPage("http://localhost")
        except Exception, err:
          log.err(err, "process getPagecall failed")
        else:
          self.setHeader('Content-Type', 'text/html')
          self.write(result)
          self.finish()

Cheers,
Andrew




      




More information about the Twisted-Python mailing list