Onion Model in Python
Project description
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"
ctx = yield ctx
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) 北京华夏春松科技有限公司
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
compose4py-1.2.0.tar.gz
(5.4 kB
view details)
Built Distribution
File details
Details for the file compose4py-1.2.0.tar.gz
.
File metadata
- Download URL: compose4py-1.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 010ab45867b0922646a195cedfc084cd1521a1e8a39a0c28026a9398b4c26cc1 |
|
MD5 | 6d31d49d5edb27f036cefef3923a0496 |
|
BLAKE2b-256 | f3548ada39e6996fc647d1dd76eac9200ff0001e4e3d5946c6bc02cd3e79cfc1 |
File details
Details for the file compose4py-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: compose4py-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2c4894e613445746e592a9836dfd4e62662daa2edbacf0845a7c970c6e81f23 |
|
MD5 | 7d36cd2c478d7bb83f86a370ccf343cd |
|
BLAKE2b-256 | 51989385bb1d107b5306e045e0348b469c51d0800a6f31b77d6024c2cfe27eb5 |