Pagination middleware for falcon framework. Pulled from py-blog project @ https://github.com/neetjn/py-blog
falcon-pagination-processor is a very simple middlware for the Falcon Web/REST framework for Python. This middleware provides pagination details in each request context based on the provided query parameters.
This project should be compaitable with any version of Falcon. Support is available for both Python 2.7 and 3.4+.
falcon-pagination-processor can be installed with pip like so:
pip install falcon-pagination-processor
Once installed, the middleware can be instantiated extending the Falcon api:
import falcon
from falcon_pagination_processor import PaginationProcessor
api = falcon.API(middleware=[PaginationProcessor()])
Pull pagination details from requests like so:
def get_resources(start, count):
"""Get paginated list of resources"""
if start and count:
return Resources[start:start+count]
return Resources
class TestResourceCollection(object):
def on_get(self, req, resp):
pagination = req.context.get('pagination')
res = get_resources(start=pagination.get('start'),
count=pagination.get('count'))
The pagination middleware looks for the start
and count
query parameters:
http://uri?start=1&count=5
- John Nolette (john@neetgroup.net)
Contributing guidelines are as follows,
- Any new features added must also be unit tested in the
tests
subdirectory.- Branches for bugs and features should be structured like so,
issue-x-username
.
- Branches for bugs and features should be structured like so,
- Include your name and email in the contributors list.
Copyright (c) 2019 John Nolette Licensed under the MIT license.