Ticket #4053: paginator-check_int.diff
File paginator-check_int.diff, 942 bytes (added by , 18 years ago) |
---|
-
core/paginator.py
1 1 class InvalidPage(Exception): 2 2 pass 3 3 4 class InvalidParameter(Exception): 5 pass 6 4 7 class ObjectPaginator(object): 5 8 """ 6 9 This class makes pagination easy. Feed it a QuerySet or list, plus the number … … 40 43 41 44 def has_next_page(self, page_number): 42 45 "Does page $page_number have a 'next' page?" 43 return page_number < self.pages - 1 46 try: 47 return int(page_number) < self.pages - 1 48 except ValueError: 49 raise InvalidParameter 44 50 45 51 def has_previous_page(self, page_number): 46 return page_number > 0 52 try: 53 return int(page_number) > 0 54 except: 55 raise InvalidParameter 47 56 48 57 def first_on_page(self, page_number): 49 58 """