Ticket #4053: paginator-check_int.diff

File paginator-check_int.diff, 942 bytes (added by meren@…, 18 years ago)
  • core/paginator.py

     
    11class InvalidPage(Exception):
    22    pass
    33
     4class InvalidParameter(Exception):
     5    pass
     6
    47class ObjectPaginator(object):
    58    """
    69    This class makes pagination easy. Feed it a QuerySet or list, plus the number
     
    4043
    4144    def has_next_page(self, page_number):
    4245        "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
    4450
    4551    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
    4756
    4857    def first_on_page(self, page_number):
    4958        """
Back to Top