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!
This commit is contained in:
Christopher Allan Webber 2013-09-13 10:16:07 -05:00
parent 66cafc3b74
commit 1fef79f4f8

View File

@ -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))