From: Zygmunt Krynicki Date: Mon, 13 Jun 2011 12:41:40 +0000 (+0200) Subject: Merge branch 'master' of git://github.com/leah/django-pagination X-Git-Tag: release-2.0~31 X-Git-Url: https://git.mdrn.pl/django-pagination.git/commitdiff_plain/993daaba73aa6511449f2c2ccfa869692afa10d5?hp=99f84ffa7a2149dd45728cea5b0b867e589aa671 Merge branch 'master' of git://github.com/leah/django-pagination Conflicts: pagination/tests.py --- diff --git a/linaro_django_pagination/__init__.py b/linaro_django_pagination/__init__.py index 8b13789..e69de29 100644 --- a/linaro_django_pagination/__init__.py +++ b/linaro_django_pagination/__init__.py @@ -1 +0,0 @@ - diff --git a/linaro_django_pagination/paginator.py b/linaro_django_pagination/paginator.py index f67aa23..8109e5e 100644 --- a/linaro_django_pagination/paginator.py +++ b/linaro_django_pagination/paginator.py @@ -1,5 +1,6 @@ from django.core.paginator import Paginator, Page, PageNotAnInteger, EmptyPage + class InfinitePaginator(Paginator): """ Paginator designed for cases when it's not important to know how many total @@ -81,8 +82,7 @@ class InfinitePage(Page): Checks for one more item than last on this page. """ try: - next_item = self.paginator.object_list[ - self.number * self.paginator.per_page] + self.paginator.object_list[self.number * self.paginator.per_page] except IndexError: return False return True @@ -107,6 +107,7 @@ class InfinitePage(Page): return self.paginator.link_template % (self.number - 1) return None + class FinitePaginator(InfinitePaginator): """ Paginator for cases when the list of items is already finite. @@ -150,6 +151,7 @@ class FinitePaginator(InfinitePaginator): page_items = self.object_list[:self.per_page] return FinitePage(page_items, number, self) + class FinitePage(InfinitePage): def has_next(self): @@ -157,7 +159,7 @@ class FinitePage(InfinitePage): Checks for one more item than last on this page. """ try: - next_item = self.paginator.object_list[self.paginator.per_page] + self.paginator.object_list[self.paginator.per_page] except IndexError: return False return True @@ -168,4 +170,4 @@ class FinitePage(InfinitePage): relative to total objects in the paginator. """ ## TODO should this holler if you haven't defined the offset? - return self.paginator.offset \ No newline at end of file + return self.paginator.offset diff --git a/linaro_django_pagination/templatetags/pagination_tags.py b/linaro_django_pagination/templatetags/pagination_tags.py index af1be0f..1e7d5da 100755 --- a/linaro_django_pagination/templatetags/pagination_tags.py +++ b/linaro_django_pagination/templatetags/pagination_tags.py @@ -272,7 +272,7 @@ def paginate(context, window=DEFAULT_WINDOW): else: to_return['getvars'] = '' return to_return - except KeyError, AttributeError: + except (KeyError, AttributeError): return {}