Brain-dead simple dependency injection
Project description
OOZE - Brain-dead simple dependency injection
Ooze is an attempt to do depdency injection in Python in the simplest way possible. It embraces Python decorators to leverage what classes, functions, and even static values are included in the dependency injection graph. You can get started in three easy steps:
- decorate your functions, classes and/or variable items
- assign a startup function
- call ooze's
run()
function
That's it! Here's a quick example:
import ooze
@ooze.provide # Inject as 'upper_case' since a name wasn't specified
def upper_case(string):
return string.upper()
ooze.provide_static('address', { # Inject a static dictionary, naming it 'address'
"name": "Steve",
"gender": "male"
})
@ooze.provide('greeter') # Inject as 'greeter'
class WelcomeWagon:
def __init__(self, upper_case, address):
self.address = address
self.upper = upper_case
def greet(self):
return self.upper(f"Hello {self.address['name']}")
@ooze.startup # Define where ooze should start running your program
def main(greeter):
print(greeter.greet())
if __name__ == '__main__':
ooze.run()
Installing Ooze
Installing Ooze is as simple as using pip:
$ pip install ooze
Usage Notes
Ooze has many features beyond what is demonstrated in the above sample code including:
- factories
- automatic environment variable injection
- automatic configuration file parsing and settings injection
- automatic (magic) integration with manually passed arguments
- seamless integration with bottlepy
- injectable object pools (i.e. Database connection pools)
Be sure to check out the documentation or examples for more information.
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
ooze-1.0.1.tar.gz
(42.9 kB
view details)
Built Distribution
ooze-1.0.1-py3-none-any.whl
(29.2 kB
view details)
File details
Details for the file ooze-1.0.1.tar.gz
.
File metadata
- Download URL: ooze-1.0.1.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b5844cfbe05d8db20e53fddd7943f7e193e29ecdf77721d5290dbd2c54269ce |
|
MD5 | 84652cb4b299dc45ce3633f76d30fef0 |
|
BLAKE2b-256 | 2dcb3f1d49c38524c09a9244047d706c96249871c8306d996b738605663bf1ad |
File details
Details for the file ooze-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ooze-1.0.1-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b37bbef1f8e9855402608fa19516315fe1e06a8b06fe579a14aefe534e5571f2 |
|
MD5 | 50b8db47b3c2292e53000e07ff445478 |
|
BLAKE2b-256 | 623c09f71a56f7b688a6b9e37b9f419a39d3f992ee09b919cfe92728bfa1e59c |