Give Pagination.get_page_url() a request instead of path and GET
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sat, 21 May 2011 14:38:34 +0000 (16:38 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Sat, 21 May 2011 14:38:34 +0000 (16:38 +0200)
Makes calling Pagination.get_page_url() much simpler.

mediagoblin/templates/mediagoblin/utils/pagination.html
mediagoblin/util.py

index b74cbfcfa7a53d938911b57ae779b87b697df087..5ca5e09bc8f0d95fee3b54462ff1abb45492294d 100644 (file)
   <div class=pagination>
 
       {% if pagination.has_prev %}
-        <a href={{ pagination.get_page_url(request.path_info, 
-                  pagination.page-1, request.GET) }}>&laquo; Prev</>
+        <a href={{ pagination.get_page_url(request, pagination.page-1) }}>&laquo; Prev</>
       {% endif %}
 
       {%- for page in pagination.iter_pages() %}
         {% if page %}
           {% if page != pagination.page %}
-           <a href={{ pagination.get_page_url(request.path_info, 
-                      page, request.GET) }}>{{ page }}</a>
+           <a href={{ pagination.get_page_url(request, page) }}>{{ page }}</a>
           {% else %}
             <strong>{{ page }}</strong>
           {% endif %}
@@ -39,8 +37,7 @@
       {%- endfor %}
 
       {% if pagination.has_next %}
-        <a href={{ pagination.get_page_url(request.path_info,  
-                   pagination.page+1, request.GET) }}>Next &raquo;</a>
+        <a href={{ pagination.get_page_url(request, pagination.page+1) }}>Next &raquo;</a>
       {% endif %}
    </div>
 {% endif %}
index d37d160eea327a4000476632102b62fa6e53ca3b..a1af7bd0ddafc1f9aeeb2ecf1a46d40db5ca3444 100644 (file)
@@ -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" % (