Added support for Norwegian Nynorsk and Norwegian Bokmål translations.
[django-pagination.git] / 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)