Commits

Christoph Haas committed 4b24e16

webhelpers.paginate: allow None as initial page number

e.g.: page=webhelpers.paginate.Page(items, page=None)

This is useful in scenarios like:

page=webhelpers.paginate.Page(items, page=request.params.get('page'))

which had formerly to be written as

page=webhelpers.paginate.Page(items, page=request.params.get('page', 1))

  • Participants
  • Parent commits f1f7cf7

Comments (0)

Files changed (1)

File webhelpers/paginate.py

         # The first page has the number 1!
         try:
             self.page = int(page) # make it int() if we get it as a string
-        except ValueError:
+        except (ValueError, TypeError):
             self.page = 1
 
         self.items_per_page = items_per_page