falcon-pagination-hook
A small falcon hook to parse pagination elements from the request.
For now it parses an Offset based pagination.
Usage
The easiest way to use this hook is the following:
@falcon.before(PaginationFromRequestHook())
def on_get(self, req, resp, user):
# Here req['context']['pagination'] is set
# with 2 keys: 'offset' and 'limit'
The Hook will look in the query parameters for 2 keys:
offset: The pagination offset
limit: The pagination limit
It will create a pagination dict into the request context accessible at req.context['pagination'].
This pagination dict will contain 2 values:
offset: The offset from the request or 0 if it doesn’t exists
limit: The limit to apply. If no limit is found the default one is applied (20). If the value is bigger than the max value (100) then the default limit is also applied.
Configuration options
A few parameters can be passed to the hook:
default_limit : The limit to apply if none is found in the request query or if the limit is out of bound. Default to 20
max_limit: Maximum allowed limit. Default to 100
offset_key: Name of the request parameter holding the offset value. Default to ‘offset’
limit_key: Name of the request parameter holding the limit value. Default to ‘limit’
Here’s an example setting a default limit to 10, a maximum limit to 500 the offset key to ‘page_offset’ and the limit key to ‘result_limit’:
@falcon.before(PaginationFromRequestHook(
default_limit=10,
max_limit=500,
offset_key='page_offset',
limit_key='result_limit'
))
def on_get(self, req, resp, user):
# Get request
Metadata
Release files for falcon-pagination 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| falcon_pagination-0.0.1.tar.gz | 3.3 kB | Without provenance | Details for falcon_pagination-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| falcon_pagination-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for falcon_pagination-0.0.1-py3-none-any.whl |
Total release size: 8.9 kB
Release files / falcon_pagination-0.0.1.tar.gz
| Download URL | falcon_pagination-0.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e20f63306edb6947886fcfbc8afd15958783d6e0a206013283eabf8a2103a528
|
|
BLAKE2b-256 checksum How to use checksums |
8bf35a5b1f23ff43ade0c59b83bc19fc8f59e5cdadbb32a86d2f6800717740a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.7
|
Release files / falcon_pagination-0.0.1-py3-none-any.whl
| Download URL | falcon_pagination-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29b3e58e4f43af02f909d6ec8b0efa78d028c2749b515ddf8980fb4b9de0c4de
|
|
BLAKE2b-256 checksum How to use checksums |
fce82ca2604ac773b09938c3f04a63eea9ddb9b68433c3dcd7f267855982d5d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.9.1 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.7
|
Security for falcon-pagination 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.