aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/util.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-05-22 17:06:11 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-05-22 17:06:11 -0500
commit50c880ac0f0d9fa90244aa8165b53a8968ae3a1a (patch)
tree3094186dccc24886a0474f11ef83772d30d1ab88 /mediagoblin/util.py
parent57c6da19ccfa035e98c1af76de2241ad3aee4093 (diff)
downloadmediagoblin-50c880ac0f0d9fa90244aa8165b53a8968ae3a1a.tar.lz
mediagoblin-50c880ac0f0d9fa90244aa8165b53a8968ae3a1a.tar.xz
mediagoblin-50c880ac0f0d9fa90244aa8165b53a8968ae3a1a.zip
A more explicit version of get_page_url that doesn't use the request
is still an option now ;)
Diffstat (limited to 'mediagoblin/util.py')
-rw-r--r--mediagoblin/util.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/mediagoblin/util.py b/mediagoblin/util.py
index f56bea43..2865cf11 100644
--- a/mediagoblin/util.py
+++ b/mediagoblin/util.py
@@ -351,13 +351,20 @@ class Pagination(object):
yield num
last = num
- def get_page_url(self, request, page_no):
+ def get_page_url_explicit(self, base_url, get_params, page_no):
"""
- Get a new page url based of the request, and the new page number.
+ Get a page url by adding a page= parameter to the base url
"""
- 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" % (
- path_info, urllib.urlencode(new_get_params))
+ 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.path_info, request.GET, page_no)