<div>Thanks, Colin.</div><div><br></div><div>In my case, I have to take 2 steps to get data from database.</div><div>1. execute sql, get a DeferredResult instance.</div><div>2. use DeferredResult.get_all/one() to get the real data.</div>
<div><br></div><div>it is a more complicated process than just one deferred.</div><div><br></div><div>Code:</div><div>def test_execute(self):</div><div>    def cb_execute(result):</div><div>        #this result is a DeferredResult, not the actual data.</div>
<div>        return result.get_one().addCallback(cb_result)</div><div><br></div><div>    def cb_result(result):</div><div>        #the data returns</div><div>         print result</div><div><br></div><div>    self.store.execute(&quot;SELECT title FROM foo WHERE id=10&quot;).addCallback(cb_execute)</div>
<div><br></div><div>    return ?</div><div><br></div><div>What should I return?</div><div><br></div><div>I execute sql statements directly using store. Possibly it is not a good choice.</div><div>If I use the ORM way:</div>
<div><br></div><div><div>    def test_get(self):</div><div>        &quot;&quot;&quot;</div><div>        Try to get an object from the store and check its attributes.</div><div>        &quot;&quot;&quot;</div><div>        def cb(result):</div>
<div>            self.assertEquals(result.title, u&#39;Title 30&#39;)</div><div>            self.assertEquals(<a href="http://result.id">result.id</a>, 10)</div><div>        return self.store.get(Foo, 10).addCallback(cb)</div>
</div><div><br></div><div>That&#39;d be much easier.</div><br><br><div class="gmail_quote">On Wed, Jul 8, 2009 at 11:22 PM, Colin Alston <span dir="ltr">&lt;<a href="mailto:karnaugh@karnaugh.za.net">karnaugh@karnaugh.za.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="h5"><br><br><div class="gmail_quote">On Wed, Jul 8, 2009 at 5:21 PM, Colin Alston <span dir="ltr">&lt;<a href="mailto:karnaugh@karnaugh.za.net" target="_blank">karnaugh@karnaugh.za.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div class="gmail_quote"><div>On Wed, Jul 8, 2009 at 4:59 PM, Daniel Yang <span dir="ltr">&lt;<a href="mailto:daniel.yang.zhenyu@gmail.com" target="_blank">daniel.yang.zhenyu@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div>Hi people,</div><div><br></div><div>I am using storm orm(<span style="font-family:&#39;Lucida Grande&#39;;font-size:12px">twisted-integration<span style="font-family:arial;font-size:small">) with Nevow.</span></span></div>



<div>There is a question that confuses me a lot:</div><div>(since storm orm(<span style="font-family:&#39;Lucida Grande&#39;;font-size:12px">twisted-integration<span style="font-family:arial;font-size:small">) does db io in a <span style="font-family:verdana,arial,&#39;Bitstream Vera Sans&#39;,helvetica,sans-serif;font-size:13px">asynchronous way).</span></span></span></div>



<div>In a render function, before my data returns, what should I return for the render function?</div><div><br></div><div>does Nevow has something like server.NOT_DONE_YET?</div><div>or there is a &quot;deferred&quot; way to do this?</div>



<div></div></blockquote></div><div><br>Hi, <br><br>You can simply use a deferred in any render function as you would expect. Nevow deals with this for you.<br><br>def render_foo(self, ctx, data):<br></div></div>
</blockquote></div>
<br></div></div>Wow.. Google mail fails and I&#39;m too used to using TAB when writing code...  <br><div class="im"><br>def render_foo(self, ctx, data):<br></div>   def continueRendering(results):<br>       # do something with results<br>
       return ctx.tag[whatever]<br>
    <br>   return myDeferredDatabaseQuery(some args).addBoth(continueRendering)<br><br><br>
<br>_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>-----------------------------------------------<br>Yours<br>Faithfully<br><br>Daniel Yang<br>