[Twisted-web] A question with storm orm and Nevow

Tristan Seligmann mithrandi at mithrandi.net
Wed Jul 8 21:59:49 EDT 2009


On Thu, Jul 9, 2009 at 3:30 AM, Daniel Yang<daniel.yang.zhenyu at gmail.com> 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



More information about the Twisted-web mailing list