# HG changeset patch # User Mads Kiilerich # Date 2016-07-28 16:28:34 # Node ID 97a4b5c47cc11d4557384b74fa4ee819d4a81a75 # Parent 19e619f3cde10d0c23f0e7afff17835f3f63c908 helpers: pass url generator function to Pager - don't rely on Pylons hack in webhelpers This makes the code less magical and helps towards TurboGears2. diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -911,6 +911,10 @@ class Page(_Page): Custom pager to match rendering style with YUI paginator """ + def __init__(self, *args, **kwargs): + kwargs.setdefault('url', url.current) + _Page.__init__(self, *args, **kwargs) + def _get_pos(self, cur_page, max_page, items): edge = (items / 2) + 1 if (cur_page <= edge): @@ -1050,12 +1054,13 @@ class Page(_Page): class RepoPage(Page): def __init__(self, collection, page=1, items_per_page=20, - item_count=None, url=None, **kwargs): + item_count=None, **kwargs): """Create a "RepoPage" instance. special pager for paging repository """ - self._url_generator = url + # TODO: call baseclass __init__ + self._url_generator = kwargs.pop('url', url.current) # Safe the kwargs class-wide so they can be used in the pager() method self.kwargs = kwargs