I have a listing site having a model with many properties on which I would like to use filters. I would like to use memcache and cursor for querying, e.g:
results=Model.all().filter("x =", a).filter("y =",b).with_cursor(cursor).fetch(20).
How should I handle cursor and pagination, when the user change the filter criteria, e.g.
from `x=a to x=c`?
Should I store cursor having key = query string? But then the query string changes with page numbers 🙁 . I guess i will need to parse query string, remove page numbers and use that as a key for cursor. Is that how I should do it?
You can make an “hash” of your current filter, and pass it to view. That can be stores there as an hidden field, like
<input type="hidden" name="prev_query" value="{{query_hash}}"/>On second request you’ll check that current filter’s hash equals to passed as parameter.
‘Hash’ maybe md5 of your filter params, or just join concatenation of them.