Django + PyCDI
A middleware to integrate PyCDI with Django.
See the code of conduct.
Install
Install pypi version
pip install django_pycdi
Install lastest version
pip install git+https://github.com/ettoreleandrotognoli/django-pycdi.git
Usage
Add middleware to settings.py:
MIDDLEWARE += ['django_pycdi.middlewares.CDIMiddleware']
Add inject decorator to your views:
With Python 2:
from random import random
from django.http import HttpResponse
from pycdi import Inject, Producer
from pycdi.utils import Singleton
@Singleton()
class MySingleton():
pass
@Producer(float)
def get_a_float():
return random()
@Inject(singleton=MySingleton,number=float)
def view(request,singleton,number):
return HttpResponse('...')
In the demo3 folder has a django demo project using python2 with more examples.
With Python 3:
from random import random
from django.http import HttpResponse
from pycdi import Inject, Producer
from pycdi.utils import Singleton
@Singleton()
class MySingleton():
pass
@Producer()
def get_a_float() -> float:
return random()
@Inject()
def view(request,singleton:MySingleton,number:float):
return HttpResponse('...')
In the demo3 folder has a django demo project using python3 with more examples.
See more ways to use PyCDI in its page.
Metadata
Release files for django-pycdi 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 | Provenance | |
|---|---|---|---|---|
| django-pycdi-0.1.0.tar.gz | 2.8 kB | Without provenance | Details |
Release files / django-pycdi-0.1.0.tar.gz
| Download URL | django-pycdi-0.1.0.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66268ea803420b542e6dd68029505a180bf4cb531e511a88d58d874fed5fac33
|
|
BLAKE2b-256 checksum How to use checksums |
6e23d5e883d13f9175844999c541b2d3367a08e3a2a2ac31ab02c454780c2843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-pycdi 0.1.0
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.