web-paging
Easy paging for the web.
Description
web-paging is a simple library for paginating through web responses.
Getting started
Install via pip (ideally in a virtualenv):
pip install web-paging
Then use the web_paging.pageable decorator to wrap any pageable view functions. E.g. if using Flask:
from functools import partial
from flask import Flask, request, render_template
import web_paging
app = Flask(__name__)
def get_flask_arg(name, default):
return request.args.get(name, default)
pageable = partial(
web_paging.pageable,
param_getter=lambda name, default: request.args.get(name, default),
full_path_getter=lambda: request.full_path,
response_factory=render_template
)
@app.get('/pageable')
@pageable('items.html')
def pageable_view(paging_key):
items, next_paging_key = find_items(paging_key=paging_key)
return dict(items=items), next_paging_key
The view is passed a paging key which can be used to identify the correct items to return. This is just a dict containing the attributes needed to find the correct results for the current page. For example, in a DynamoDB Query this dict would contain the attributes needed to create the ExclusiveStartKey. Similarly, the next_paging_key would be a dict created from the LastEvaluatedKey, containing the attributes needed to create the ExclusiveStartKey for the next page.
The response_factory function (flask.render_template in the example above) is passed the template name and a context object, containing the context returned from the view function (dict(items=items) in this example), plus a context variable to render pagination links:
{% if web_paging.paging_tokens %}
<p>
{% if web_paging.previous_path %}
<a href="{{ web_paging.previous_path }}">
Previous page
</a>
{% endif %}
{% if web_paging.next_path %}
<a href="{{ web_paging.next_path }}">
Next page
</a>
{% endif %}
</p>
{% endif %}
web_paging.previous_path and web_paging.next_path are instances of markupsafe.Markup.
The context also includes a couple of variables representing the page numbers of the previous and next pages. These variables are web_paging.next_page and web_paging.previous_page.
Flask Support
web-paging has built-in support for Flask. Install with:
pip install "web-paging[flask]"
Then you can use the web_paging.flask_pageable decorator:
from web_paging import flask_pageable
@app.get('/pageable')
@flask_pageable('items.html')
def pageable_view(paging_key):
items, next_paging_key = find_items(paging_key=paging_key)
return dict(items=items), next_paging_key
Metadata
Release files for web-paging 0.3.0
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 |
|---|---|---|---|---|
| web_paging-0.3.0.tar.gz | 5.2 kB | With provenance | Details for web_paging-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| web_paging-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for web_paging-0.3.0-py3-none-any.whl |
Total release size: 10.3 kB
Release files / web_paging-0.3.0.tar.gz
| Download URL | web_paging-0.3.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f236f9c1092308be4671532f3377121d310d4bbd8831408eb5788c1771a829a8
|
|
BLAKE2b-256 checksum How to use checksums |
074b1e01851742d46fe2fd0c60628aeae4d4283dc847a4433f5d365749986cc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 10, 2025.
Transparency logRelease files / web_paging-0.3.0-py3-none-any.whl
| Download URL | web_paging-0.3.0-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6b993094d90614debae6de12453500e333514285b3394f9fadb868ee2090509
|
|
BLAKE2b-256 checksum How to use checksums |
2a47a105a20ee0275e1243bf9fc50233e46e62f9bfd5e21f41db789e7b74f6ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 10, 2025.
Transparency logSecurity for web-paging 0.3.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for web_paging-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 10, 2025.
Transparency logA 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.