CNSdi-0.1.4
توضیحات
Simple Dependency Injection for python
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | CNSdi-0.1.4 |
| نام | CNSdi |
| نسخه کتابخانه | 0.1.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Scott Scoble |
| ایمیل نویسنده | sscoble@codesmith.ws |
| آدرس صفحه اصلی | http://wscoble.github.io/CNSdi |
| آدرس اینترنتی | https://pypi.org/project/CNSdi/ |
| مجوز | LICENSE.txt |
======
CNS DI
======
CNS Dependency Injection is a very simple way to store and inject services into your software.
It looks like this for Flask (dumb example, but you should get the point)::
from di.helpers import get_service, add_service
from di.decorator import service, inject
from flask import Flask
app = Flask(__name__)
add_service('router', app.route)
@service('adder')
def adder(*args):
sum = 0
for arg in args:
sum += arg
return sum
router = get_service('router')
@router('/adds')
def adds():
sum = get_service('adder')([1,2,3])
return "hello " + repr(sum)
get_service('app').run()
If you are going to @inject into a class, do it on the __init__ function. @service can be used with classes or functions.
نحوه نصب
نصب پکیج whl CNSdi-0.1.4:
pip install CNSdi-0.1.4.whl
نصب پکیج tar.gz CNSdi-0.1.4:
pip install CNSdi-0.1.4.tar.gz