Skip to content

Pagination Helper #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

rugginoso
Copy link

I'm not sure this is the right way.
Actualy the module monkey-patches the pymongo.cursor.Cursor to add the paginate method.
It's also possible to remove this behaviour and use paginate() passing the cursor as argument.

This should fix #2

@dcrosta
Copy link
Contributor

dcrosta commented Dec 1, 2013

Unforunately, efficient pagination is a little harder than you might like with MongoDB -- basically, when you use slices on a cursor, this is internally translated to a skip command on the server side. If the command asks the server to skip many records, this can be slow on the server, which results in a (potentially long) delay for the client.

At the very least, this needs a major "caveat emptor"-type comment in the docstring, possibly pointing the unwary user at some information about when and how pagination can be slow (you can google for "mongodb pagination" and find many questions and blog posts about the topic).

Regarding monkey-patching, see the pattern I use in wrappers.py -- I think that would be a more appropriate approach here. I think it would also be nice if the result of a call to paginate() were iterable, as this would be a more natural way to use it in templates, etc.

@ranman ranman closed this Jan 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pagination Helper
3 participants