Mercurial > kallithea
changeset 6049:97a4b5c47cc1
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.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Thu, 28 Jul 2016 16:28:34 +0200 |
parents | 19e619f3cde1 |
children | 17f9f921a538 |
files | kallithea/lib/helpers.py |
diffstat | 1 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/helpers.py Thu Jul 28 16:28:34 2016 +0200 +++ b/kallithea/lib/helpers.py Thu Jul 28 16:28:34 2016 +0200 @@ -911,6 +911,10 @@ 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 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