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




      

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to