Extracted fragment extraction in bookfragments to extract_fragments function. Put...
[wolnelektury.git] / pagination / middleware.py
1 class PaginationMiddleware(object):
2     """
3     Inserts a variable representing the current page onto the request object if
4     it exists in either **GET** or **POST** portions of the request.
5     """
6     def process_request(self, request):
7         try:
8             request.page = int(request.REQUEST['page'])
9         except (KeyError, ValueError):
10             request.page = 1