| Stephen Thorne ( @ 2005-09-06 09:33:00 |
funky 2.5 defgen
This is the new syntax for using the new 2.5 generators with twisted.
which is an analog of the 'old' way of doing things, like this:
Yay to christopher armstrong for putting this together, yay to PJE for writing the code for python2.5
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