funky 2.5 defgen
This is the new syntax for using the new 2.5 generators with twisted.
@defgen
def foo():
value = yield someDeferredAction()
row = yield someDatabaseQuery(value+1)
yield row['column']
which is an analog of the 'old' way of doing things, like this:
def foo():
def _increment(value):
return value+1
def _getcolumn(row):
return row['column']
return someDeferredAction(
).addCallback(_increment
).addCallback(someDatabaseQuery
).addCallback(_getcolumn)Yay to christopher armstrong for putting this together, yay to PJE for writing the code for python2.5