Compose4py
Onion Model in Python. Pyton 洋葱模型
pip install compose4py
Installation
Usage
Import compose4py:
from compose4py import Compose
All the usual function composition you know and love:
def mw_1(ctx, loader_context):
print("mw_1: %s" % ctx)
print("mw_1 loader_context: %s" % loader_context)
ctx += ":mw1"
# call the next middleware and waiting the new ctx
ctx = yield ctx
# use the latest ctx and process more logic
ctx += ":post_mw1"
return ctx
def mw_2(ctx):
print("mw_2: %s" % ctx)
ctx += ":mw2"
ctx = yield ctx
ctx += ":post_mw2"
return ctx
def mw_3(ctx):
print("mw_3: %s" % ctx)
ctx += ":mw3"
return ctx
compose = Compose(mw_1, mw_2, mw_3, loader_context = {"foo": "bar"})
result = compose("foo")
print("final: %s" % result)
# final: foo:mw1:mw2:mw3:post_mw2:post_mw1
Give credits to
开源许可协议
Copyright (2018-2020) 北京华夏春松科技有限公司
Metadata
Release files for compose4py 1.3.3
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 |
|---|---|---|---|---|
| compose4py-1.3.3.tar.gz | 5.6 kB | Without provenance | Details for compose4py-1.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| compose4py-1.3.3-py3-none-any.whl | Python 3 | none | any | Details for compose4py-1.3.3-py3-none-any.whl |
Total release size: 12.9 kB
Release files / compose4py-1.3.3.tar.gz
| Download URL | compose4py-1.3.3.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16a966aa33024d63afff6dcb7da107634d1945fbe8f12d418008f66e0509bfdc
|
|
BLAKE2b-256 checksum How to use checksums |
1055fb9a20cfc5a1f413101ba53a8120308cdacf39a03bead973b788ef0c76fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2
|
Release files / compose4py-1.3.3-py3-none-any.whl
| Download URL | compose4py-1.3.3-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a79f2822a7d474050c9ebf5f337f43969ef46af88e9f4d50d82a7e4862260472
|
|
BLAKE2b-256 checksum How to use checksums |
42696bc35e257659ea25f67642f5c749aab0a5fe371740ead02b2c2c6bb9d363
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.2
|
Security for compose4py 1.3.3
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.