Bump version to 1.0.7.1 to distinguish from upstream release
[django-pagination.git] / linaro_django_pagination / middleware.py
1 def get_page(self):
2     """
3     A function which will be monkeypatched onto the request to get the current
4     integer representing the current page.
5     """
6     try:
7         return int(self.REQUEST['page'])
8     except (KeyError, ValueError, TypeError):
9         return 1
10
11 class PaginationMiddleware(object):
12     """
13     Inserts a variable representing the current page onto the request object if
14     it exists in either **GET** or **POST** portions of the request.
15     """
16     def process_request(self, request):
17         request.__class__.page = property(get_page)