From 0e84c707cb57b864fff4bdd438644c4313677893 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sat, 21 May 2011 16:38:34 +0200 Subject: [PATCH 1/2] Give Pagination.get_page_url() a request instead of path and GET Makes calling Pagination.get_page_url() much simpler. --- mediagoblin/templates/mediagoblin/utils/pagination.html | 9 +++------ mediagoblin/util.py | 8 ++++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/utils/pagination.html b/mediagoblin/templates/mediagoblin/utils/pagination.html index b74cbfcf..5ca5e09b 100644 --- a/mediagoblin/templates/mediagoblin/utils/pagination.html +++ b/mediagoblin/templates/mediagoblin/utils/pagination.html @@ -21,15 +21,13 @@ {% endif %} diff --git a/mediagoblin/util.py b/mediagoblin/util.py index d37d160e..a1af7bd0 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -29,8 +29,6 @@ from mediagoblin import globals as mgoblin_globals import urllib from math import ceil import copy -import decorators -from webob import exc TESTS_ENABLED = False def _activate_testing(): @@ -353,11 +351,13 @@ class Pagination(object): yield num last = num - def get_page_url(self, path_info, page_no, get_params=None): + def get_page_url(self, request, page_no): """ - Get a new page based of the path_info, the new page number, + Get a new page based of the request, the new page number, and existing get parameters. """ + path_info = request.path_info + get_params = request.GET new_get_params = copy.copy(get_params or {}) new_get_params['page'] = page_no return "%s?%s" % ( From 538a06e986a4ebebf5f670dd3d5af9ddb9501649 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sat, 21 May 2011 17:02:49 +0200 Subject: [PATCH 2/2] Fix doc string of get_page_url() --- mediagoblin/util.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mediagoblin/util.py b/mediagoblin/util.py index a1af7bd0..f56bea43 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -353,8 +353,7 @@ class Pagination(object): def get_page_url(self, request, page_no): """ - Get a new page based of the request, the new page number, - and existing get parameters. + Get a new page url based of the request, and the new page number. """ path_info = request.path_info get_params = request.GET @@ -362,4 +361,3 @@ class Pagination(object): new_get_params['page'] = page_no return "%s?%s" % ( path_info, urllib.urlencode(new_get_params)) -