bottle-argsmap-0.1.1
توضیحات
-
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | bottle-argsmap-0.1.1 |
| نام | bottle-argsmap |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Cologler |
| ایمیل نویسنده | skyoflw@gmail.com |
| آدرس صفحه اصلی | https://github.com/Cologler/bottle_argsmap-python |
| آدرس اینترنتی | https://pypi.org/project/bottle-argsmap/ |
| مجوز | MIT |
# bottle_argsmap
Auto inject arguments via a `dict` like pattern.
## Usage
``` py
from bottle import Bottle
from bottle_argsmap import ArgsMapPlugin
app = Bottle()
plugin = try_install(app)
# inject via singleton
plugin.set_value('value', '1544')
# or inject via factory, dynamic creation is allowed
# e.g. you can to inject database connection from a database pool
plugin.set_factory('value',
lambda param_name, route: ...,
context_manager=True, # auto call `__exit__` on the value after responsed
)
# finally, inject it
@app.get('/path')
def get_it(value): # value is injected
return dict(value=value)
```
## More
`ArgsMapPlugin().ioc` is a instance of type `anyioc.ServiceProvider`, which means you can use all features from `anyioc`.
نیازمندی
| مقدار | نام |
|---|---|
| >=0.12.19,<0.13.0 | bottle |
| >=0.11.1,<0.12.0 | anyioc |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0 | Python |
نحوه نصب
نصب پکیج whl bottle-argsmap-0.1.1:
pip install bottle-argsmap-0.1.1.whl
نصب پکیج tar.gz bottle-argsmap-0.1.1:
pip install bottle-argsmap-0.1.1.tar.gz