Thanks, Tristan and Colin. Yes. the code was taken from storm unittests. I was planning to do some rendering work in cb_result. Let me try first.
On Thu, Jul 9, 2009 at 9:59 AM, Tristan Seligmann <[email protected]>wrote: > On Thu, Jul 9, 2009 at 3:30 AM, Daniel Yang<[email protected]> > wrote: > > def test_execute(self): > > This looks like a unit test, not Nevow code? > > > def cb_execute(result): > > #this result is a DeferredResult, not the actual data. > > return result.get_one().addCallback(cb_result) > > def cb_result(result): > > #the data returns > > print result > > Return your ultimate result here; note that if you're not actually > going to do anything to result in cb_result, you could just have: > > def cb_execute(result): > return result.get_one() > > > self.store.execute("SELECT title FROM foo WHERE > id=10").addCallback(cb_execute) > > return ? > > return self.store.execute("SELECT title FROM foo WHERE > id=10").addCallback(cb_execute) > > The result returned from cb_result is what will ultimately used by > whatever invoked test_execute, assuming that it pays attention to the > return value; I'm not clear how test_execute is being used, so I can't > say this will work for sure. If test_execute is, for example, a render > method, then it should work just fine. > -- > mithrandi, i Ainil en-Balandor, a faer Ambar > > _______________________________________________ > Twisted-web mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web > -- ----------------------------------------------- Yours Faithfully Daniel Yang
_______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
