On Tue, Jun 09, 2009 at 05:31:52PM +0800, hoooooosety wrote:
> Is there a common way to solve the problem like this. I mean I can
> still keep the separate functions as the look like now,

I do it like this:

    def deferCompoundFunc(paramA, paramB):
        d = deferDoSomeInsert(paramA, paramB)
        d.addCallback(lambda ignored: deferDoSomeDelete(paramA, paramB))
        return d

(Actually I normally call the lambda's parameter "_" rather than
"ignored" because it's faster to type, and makes pylint not complain
about unused variables)

If you're learning Twisted for the first time, get prepared to get very
friendly with lambda. :)

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

Reply via email to