Another simple ioc framework for python
Project description
anyioc
Another simple ioc framework for python.
Usage
from anyioc import ServiceProvider
provider = ServiceProvider()
provider.register_singleton('the key', lambda ioc: 102) # ioc will be a `IServiceProvider`
value = provider.get('the key')
assert value == 102
Register and resolve
By default, you can use following methods to register services:
ServiceProvider.register_singleton(key, factory)
ServiceProvider.register_scoped(key, factory)
ServiceProvider.register_transient(key, factory)
ServiceProvider.register(key, factory, lifetime)
ServiceProvider.register_value(key, value)
ServiceProvider.register_group(key, keys)
ServiceProvider.register_bind(new_key, target_key)
And use following methods to resolve services:
ServiceProvider.__getitem__(key)
ServiceProvider.get(key)
ServiceProvider.get_many(key)
get
return None
if the service was not found, but __getitem__
will raise a ServiceNotFoundError
.
Read full documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
anyioc-0.12.1.tar.gz
(13.6 kB
view details)
Built Distribution
anyioc-0.12.1-py3-none-any.whl
(17.9 kB
view details)
File details
Details for the file anyioc-0.12.1.tar.gz
.
File metadata
- Download URL: anyioc-0.12.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46af35c2225ed3a405aaa034dc49d20b7d2f1ff3feb7467a47795f66a0780229 |
|
MD5 | 456c03c9de0f7d17055a92f64e370134 |
|
BLAKE2b-256 | 1d7923e6ef46a912db7671728282cfd09362aa5f3900cdf2334a60014d23bdbd |
File details
Details for the file anyioc-0.12.1-py3-none-any.whl
.
File metadata
- Download URL: anyioc-0.12.1-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b65d8c6e58472465d69b51b7b3df8118a2a27a9e3a3bc4606c8f099552fe694 |
|
MD5 | 6a44de9a23dd6b968104e0fc2e07f901 |
|
BLAKE2b-256 | f26c0563b9f270d37ff1c2919d0cbdf45f5c93f1f4fc3ad84dc68759a5f114a0 |