Flask pypendency extension
Flask extension for Pypendency. Pypendency is a dependency injection library for python 3.6+.
Installation
To install from source, download the source code, then run this:
python setup.py install
Or install with pip:
pip install Flask-Pypendency
Integration with Flask
Adding the extension to your Flask app is simple:
from flask import Flask
from flask_pypendency import Pypendency
app = Flask(__name__)
pypendency = Pypendency(app)
Usage
Anywhere in your app, you will be able to access the container using the app
from flask import current_app as app
@app.route('/hello')
def hello():
service = pypendency.container.get('my.service')
return service.say_hello()
Configuration
The Flask App could be configure before the init_app of Flask-Pypendency, with the following parameteres:
PYPENDENCY_DI_FOLDER_NAME
Specify the name of the folder containing the definitions of services, it should be the same across all the app (if more than one path is defined).
Default:
_dependency_injection
PYPENDENCY_DISCOVER_PATHS
Iterable of absolute paths where to search for definitions of services
Default: Flask's app root path
Examples
The file test/test_flask_pypendency.py has a end-to-end test that shows how the extension could
be used on a real Flask app.
Contributing / Running project locally
Build the docker image:
docker build . -t flask-pypendency-dev
Run tests:
docker run -v $(pwd)/.:/usr/src/app flask-pypendency-dev bash -c "pipenv run make run-tests"
Metadata
Release files for Flask-Pypendency 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Flask-Pypendency-0.1.0.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Flask_Pypendency-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.8 kB
Release files / Flask-Pypendency-0.1.0.tar.gz
| Download URL | Flask-Pypendency-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6b00589b3fee9a274d5c527ce45034951571642b7e100154d51b3f3f2efd8fc
|
|
BLAKE2b-256 checksum How to use checksums |
78b2e5f2c9b2c7de88ca3a3136e2e055111d8a27f0ce203ea8cea9320f113eb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|
Release files / Flask_Pypendency-0.1.0-py3-none-any.whl
| Download URL | Flask_Pypendency-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
32809f31003bb94d25ae0e30d0ba9bc4c744d797a06bc4974add3b71a603a763
|
|
BLAKE2b-256 checksum How to use checksums |
a9329b3b2d7fa035f94fcc9c185bb84e1b749a61b1806cb9966384c8a0c73aa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|