This release is a pre-release and may not be stable for production use.
Wouldn’t it be nice if writing correct WSGI middleware was this simple?
>>> from wsgi_lite import lite, lighten >>> def latinator(app): ... ... # Make sure that `app` can be invoked via the Lite protocol, even ... # if it's a standard WSGI 1 app: ... app = lighten(app) ... ... @lite ... def middleware(environ): ... status, headers, body = app(environ) ... for name, value in headers: ... if name.lower()=='content-type' and value=='text/plain': ... break ... else: ... # Not text/plain, pass the request through unchanged ... return status, headers, body ... ... # Strip content-length if present, else it'll be wrong ... headers = [ ... (name, value) for name, value in headers ... if name.lower() != 'content-length' ... ] ... return status, headers, (piglatin(data) for data in body) ... ... return middleware
Using just two decorators, WSGI Lite lets you create correct and compliant middleware and applications, without needing to worry about start_response, write and close calls. And with those same two decorators, it also lets you manage resources to be released at the end of a request, and automatically pass in keyword arguments to your apps or middleware that are obtained from the WSGI environment (like WSGI server extensions or middleware-supplied parameters such as request or session objects).
For more details, check out the project’s home page on BitBucket, and scroll down to the table of contents.
WSGI Lite is currently only available for Python 2.x (tested w/2.3 up to 2.7) but the source should be quite portable to 3.x, as its magic is limited to inspecting function argument names, and cloning functions using new.function().
Metadata
Release files for wsgi_lite 0.5a3-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 |
|---|---|---|---|---|
| wsgi_lite-0.5a3-1.tar.gz | 26.8 kB | Without provenance | Details for wsgi_lite-0.5a3-1.tar.gz |
Release files / wsgi_lite-0.5a3-1.tar.gz
| Download URL | wsgi_lite-0.5a3-1.tar.gz |
|---|---|
| Size | 26.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a29a835cfc52bab11959e8d8104a94b6be33403d118c04533ea764407b7fa960
|
|
BLAKE2b-256 checksum How to use checksums |
80caf3b3ff345a5981555d6d80bffd6f04ebfc77768cc65a057f51a6e702d7fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for wsgi_lite 0.5a3-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.