[Twisted-web] A question with storm orm and Nevow
daniel.yang.zhenyu at gmail.com
Wed Jul 8 21:30:31 EDT 2009
In my case, I have to take 2 steps to get data from database.
1. execute sql, get a DeferredResult instance.
2. use DeferredResult.get_all/one() to get the real data.
it is a more complicated process than just one deferred.
#this result is a DeferredResult, not the actual data.
#the data returns
self.store.execute("SELECT title FROM foo WHERE
What should I return?
I execute sql statements directly using store. Possibly it is not a good
If I use the ORM way:
Try to get an object from the store and check its attributes.
self.assertEquals(result.title, u'Title 30')
return self.store.get(Foo, 10).addCallback(cb)
That'd be much easier.
On Wed, Jul 8, 2009 at 11:22 PM, Colin Alston <karnaugh at karnaugh.za.net>wrote:
> 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?
>> 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)
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-web