[Twisted-web] A question with storm orm and Nevow
Daniel Yang
daniel.yang.zhenyu at gmail.com
Wed Jul 8 22:18:34 EDT 2009
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
<mithrandi at mithrandi.net>wrote:
> 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
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
--
-----------------------------------------------
Yours
Faithfully
Daniel Yang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20090709/a2755051/attachment.htm
More information about the Twisted-web
mailing list