diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-09-13 10:16:07 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2013-09-13 10:16:07 -0500 |
commit | 1fef79f4f884c9e534b6f892cd2e448fc5e483eb (patch) | |
tree | 5c912f4e76f209ce5b1a9740435cb31458b99691 | |
parent | 66cafc3b74d476710013efb46341b989028f3057 (diff) | |
download | mediagoblin-1fef79f4f884c9e534b6f892cd2e448fc5e483eb.tar.lz mediagoblin-1fef79f4f884c9e534b6f892cd2e448fc5e483eb.tar.xz mediagoblin-1fef79f4f884c9e534b6f892cd2e448fc5e483eb.zip |
Fix pagination for certain request.GET data
This didn't work at all nicely with MultiDict objects in various
circumstances and could possibly break pagination. This fix handles
that!
This commit sponsored by Alessandro Francolini. Thank you!
-rw-r--r-- | mediagoblin/tools/pagination.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mediagoblin/tools/pagination.py b/mediagoblin/tools/pagination.py index d0f08c94..855878e0 100644 --- a/mediagoblin/tools/pagination.py +++ b/mediagoblin/tools/pagination.py @@ -18,7 +18,7 @@ import urllib import copy from math import ceil, floor from itertools import izip, count - +from werkzeug.datastructures import MultiDict PAGINATION_DEFAULT_PER_PAGE = 30 @@ -98,7 +98,11 @@ class Pagination(object): """ Get a page url by adding a page= parameter to the base url """ - new_get_params = dict(get_params) or {} + if isinstance(get_params, MultiDict): + new_get_params = get_params.to_dict() + else: + new_get_params = dict(get_params) or {} + new_get_params['page'] = page_no return "%s?%s" % ( base_url, urllib.urlencode(new_get_params)) |