Framework agnostic implementation of the unpoly server-protocol.
Project description
Unpoly
Unpoly is a framework agnostic python library implementing the Unpoly server protocol.
Features
- Full protocol implementation: The whole Unpoly server protocol is implemented and well tested.
- Django support: Out of the box we currently ship a middleware for Django support.
- Easily extendable: The library abstracts the actual HTTP stuff via adapters and can easily plugged into frameworks like Flask etc.
Download & Install
pip install unpoly
Usage with Django
Add unpoly.contrib.django.UnpolyMiddleware
to your middlewares and then you can access request.up
. Details can be found in the usage section of the docs.
Example usage:
def my_view(request):
if request.up: # Unpoly request
# Send an event down to unpoly
request.up.emit("test:event", {"event": "params"})
# ... and also clear the cache for certain paths
request.up.expire("/users/*")
else:
...
def form_view(request):
form = MyForm(request.GET)
# When unpoly wants to validate a form it sends
# along X-Up-Validate which contains the field
# being validated.
if form.is_valid() and not request.up.validate:
form.save()
return render(request, "template.html", {"form": form})
Usage with Flask etc
Subclass unpoly.adapter.BaseAdapter
and initialize unpoly.Unpoly
with it for every request (see the docs for details).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unpoly-3.0.0rc1.tar.gz
(35.9 MB
view hashes)
Built Distribution
unpoly-3.0.0rc1-py3-none-any.whl
(10.1 kB
view hashes)
Close
Hashes for unpoly-3.0.0rc1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21e3e3916aa5f64d3aaf9a6b255970ddd1b1bf00cdf5aa4069ebc371a3e5ea44 |
|
MD5 | cf70f7d5839f0bdd37ed926c366cd4d0 |
|
BLAKE2b-256 | a824a08962c567ed3e1563ba23161b315af5a7f90a6d09b3d2d14174625692b5 |