[web2py] Re: DAL Challenge

2012-03-28 Thread Wikus van de Merwe
First you need to change your model. In relation database you would have: db.define_table("articles", db.Field("title"), ...) db.define_table("comments", db.Field("article_id", db.articles), db.Field("author"), ...) But with datastore you want to do the reverse, keep the comment ids in the artic

[web2py] Re: DAL Challenge

2012-03-27 Thread Udi Milo
Thanks! I'm trying to follow the logic of your suggestion all the way to rendering it, tell me if you have a better idea: once I hold the list of articles I want to show, I run over the list and get all the comment ids, I issue a large query with the ids of all comments for all articles togethe

[web2py] Re: DAL Challenge

2012-03-27 Thread Massimo Di Pierro
I guess we could modify the cache object to to this automagically. Open a ticket about it. On Monday, 26 March 2012 17:57:15 UTC-5, Udi Milo wrote: > > Hi guys, > > I have an entity called article. > I want to build the ability to comment on each article. comment at least > need (created_on, use

[web2py] Re: DAL Challenge

2012-03-27 Thread Niphlod
On the cache side. function test(x): if cache.ram('key_%s' % x, 5): return cache.ram('key_%s' % x, 5) else: . cache.ram('key_%s' % x, lambda: x , 5)

[web2py] Re: DAL Challenge

2012-03-27 Thread Wikus van de Merwe
When working with GAE datastore you want to execute minimum number of queries necessary to avoid delays and limit the use of DB API calls. Fetching comments one by one is not the best option then (even if done with ajax). Probably the most efficient way would be to store the list of comment ids