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

Colin Alston karnaugh at karnaugh.za.net
Wed Jul 8 11:22:49 EDT 2009


On Wed, Jul 8, 2009 at 5:21 PM, Colin Alston <karnaugh at karnaugh.za.net>wrote:

> On Wed, Jul 8, 2009 at 4:59 PM, Daniel Yang <daniel.yang.zhenyu at gmail.com>wrote:
>
>> Hi people,
>>
>> I am using storm orm(twisted-integration) with Nevow.
>> There is a question that confuses me a lot:
>> (since storm orm(twisted-integration) does db io in a asynchronous way).
>> In a render function, before my data returns, what should I return for the
>> render function?
>>
>> does Nevow has something like server.NOT_DONE_YET?
>> or there is a "deferred" way to do this?
>>
>
> Hi,
>
> You can simply use a deferred in any render function as you would expect.
> Nevow deals with this for you.
>
> def render_foo(self, ctx, data):
>

Wow.. Google mail fails and I'm too used to using TAB when writing code...

def render_foo(self, ctx, data):
   def continueRendering(results):
       # do something with results
       return ctx.tag[whatever]

   return myDeferredDatabaseQuery(some args).addBoth(continueRendering)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20090708/34db623a/attachment.htm 


More information about the Twisted-web mailing list