In trunk with a minor change. Please make sure I did not break your patch.

massimo

On Saturday, 16 June 2012 13:59:34 UTC-5, howesc wrote:
>
> Hello again,
>
> I wanna use cursors on my GAE queries: 
> https://developers.google.com/appengine/docs/python/datastore/queries#Query_Cursors
>
> i have attached a patch that adds an optional parameter "reusecursor" to 
> select on GAE.  If True, and the query has a limitby, it indicates that 
> db['_lastcursor'] will have the cursor (i didn't want to store it if you 
> are not gonna use it because i'm not sure of the cost of getting that 
> cursor).  If a reusecursor is a string that string will be passed to the 
> GAE query as the cursor.  Note that you must use limitby on all queries 
> that you want to return the cursor for, and that queries that use a cursor 
> must have the exact same filters.  Keep in mind that limitby will be in 
> relation to the cursor, so in most cases you want offset of 0.
>
> my suggested patch is attached.  i welcome comments.
>
> example:
>
> def test3():
>     cursor = request.vars.cursor or True
>
>     #say the manu_item has about a hundred rows....
>     rows = db(db.menu_item.id>0).select(reusecursor=cursor, 
> limitby=(0,10))
>     cursor = db['_lastcursor']
>     next_link = A('next', _href=URL(r=request, vars={'cursor':cursor}))
>     
>     
>     # Use generic HTML views
>     response.generic_patterns = ['html']
>     return dict(
>         rows=rows,
>         cursor=cursor,
>         next_link = next_link)
>
> thanks,
>
> christian
>

Reply via email to