aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools
diff options
context:
space:
mode:
authorBen Sturmfels <ben@sturm.com.au>2016-08-07 21:48:52 +1000
committerBoris Bobrov <breton@cynicmansion.ru>2016-09-16 09:24:56 +0300
commit58b3a65e53c70d6e0bffb8645cb947e17773fc0f (patch)
tree575074d94f755f816d7d3d79ed9d9f1eabcf9a78 /mediagoblin/tools
parentd37c6f622a33fc3e0e37f84d1e90d287794d0a04 (diff)
downloadmediagoblin-58b3a65e53c70d6e0bffb8645cb947e17773fc0f.tar.lz
mediagoblin-58b3a65e53c70d6e0bffb8645cb947e17773fc0f.tar.xz
mediagoblin-58b3a65e53c70d6e0bffb8645cb947e17773fc0f.zip
Add Python 3 support in pagination.
This issue was visible when attempting to view the home page of a MediaGoblin site with more than a single page worth of items, under Python 3.
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r--mediagoblin/tools/pagination.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/mediagoblin/tools/pagination.py b/mediagoblin/tools/pagination.py
index a525caf7..db5f69fb 100644
--- a/mediagoblin/tools/pagination.py
+++ b/mediagoblin/tools/pagination.py
@@ -14,13 +14,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import urllib
import copy
from math import ceil, floor
from itertools import count
from werkzeug.datastructures import MultiDict
-from six.moves import zip
+from six.moves import range, urllib, zip
PAGINATION_DEFAULT_PER_PAGE = 30
@@ -86,7 +85,7 @@ class Pagination(object):
def iter_pages(self, left_edge=2, left_current=2,
right_current=5, right_edge=2):
last = 0
- for num in xrange(1, self.pages + 1):
+ for num in range(1, self.pages + 1):
if num <= left_edge or \
(num > self.page - left_current - 1 and \
num < self.page + right_current) or \
@@ -107,7 +106,7 @@ class Pagination(object):
new_get_params['page'] = page_no
return "%s?%s" % (
- base_url, urllib.urlencode(new_get_params))
+ base_url, urllib.parse.urlencode(new_get_params))
def get_page_url(self, request, page_no):
"""