diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-11-13 20:23:26 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-11-13 20:23:26 -0600 |
commit | ee91c2b88d1a42b9d15d34d2c081cd8394649041 (patch) | |
tree | 01a75b958b2814763a0b219145bbe284d1d04931 /mediagoblin/tools/pagination.py | |
parent | 4671fda345394dad9ca4278b1cf7b2cdf7d2b4ee (diff) | |
parent | 285ffeddf3542201b83072d3be544c85e9c487c2 (diff) | |
download | mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.lz mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.tar.xz mediagoblin-ee91c2b88d1a42b9d15d34d2c081cd8394649041.zip |
Merge remote-tracking branch 'remotes/nyergler/pep8-ification'
Conflicts:
mediagoblin/db/migrations.py
mediagoblin/db/models.py
mediagoblin/user_pages/views.py
mediagoblin/util.py
Diffstat (limited to 'mediagoblin/tools/pagination.py')
-rw-r--r-- | mediagoblin/tools/pagination.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mediagoblin/tools/pagination.py b/mediagoblin/tools/pagination.py index 3ea96e6d..bc20ec90 100644 --- a/mediagoblin/tools/pagination.py +++ b/mediagoblin/tools/pagination.py @@ -19,8 +19,10 @@ import copy from math import ceil, floor from itertools import izip, count + PAGINATION_DEFAULT_PER_PAGE = 30 + class Pagination(object): """ Pagination class for mongodb queries. @@ -37,9 +39,9 @@ class Pagination(object): Args: - page: requested page - per_page: number of objects per page - - cursor: db cursor - - jump_to_id: ObjectId, sets the page to the page containing the object - with _id == jump_to_id. + - cursor: db cursor + - jump_to_id: ObjectId, sets the page to the page containing the + object with _id == jump_to_id. """ self.page = page self.per_page = per_page @@ -91,19 +93,19 @@ class Pagination(object): last = num def get_page_url_explicit(self, base_url, get_params, page_no): - """ + """ Get a page url by adding a page= parameter to the base url - """ + """ new_get_params = copy.copy(get_params or {}) new_get_params['page'] = page_no return "%s?%s" % ( base_url, urllib.urlencode(new_get_params)) def get_page_url(self, request, page_no): - """ + """ Get a new page url based of the request, and the new page number. This is a nice wrapper around get_page_url_explicit() - """ + """ return self.get_page_url_explicit( request.full_path, request.GET, page_no) |