@@ -0,0 +1,566 @@
+def get_page(self):%0A    %22%22%22%0A    A function which will be monkeypatched onto the request to get the current%0A    integer representing the current page.%0A    %22%22%22%0A    try:%0A        return int(self.REQUEST%5B'page'%5D)%0A    except (KeyError, ValueError, TypeError):%0A        return 1%0A%0A%0Aclass PaginationMiddleware(object):%0A    %22%22%22%0A    Inserts a variable representing the current page onto the request object if%0A    it exists in either **GET** or **POST** portions of the request.%0A    %22%22%22%0A    def process_request(self, request):%0A        request.__class__.page = property(get_page)%0A

Create middleware.py