https://github.com/rande/python-simple-ioc
A simple Python IOC based on Symfony2 Dependency Component
https://github.com/rande/python-simple-ioc
Last synced: about 1 year ago
JSON representation
A simple Python IOC based on Symfony2 Dependency Component
- Host: GitHub
- URL: https://github.com/rande/python-simple-ioc
- Owner: rande
- License: apache-2.0
- Created: 2013-03-11T23:50:49.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-09-14T23:44:38.000Z (almost 12 years ago)
- Last Synced: 2025-03-18T02:44:15.676Z (over 1 year ago)
- Language: Python
- Homepage: https://python-ioc.readthedocs.org/
- Size: 688 KB
- Stars: 24
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
- License: LICENSE
Awesome Lists containing this project
README
============================================
Python Simple Dependency Injection Container
============================================
This project is a simple port of the Symfony2 DependencyInjection lib available at https://github.com/symfony/DependencyInjection
Status: Work In Progress
Usage
-----
- Create a services.yml file, the file will contains different service definiton such as
.. code-block:: yaml
parameters:
foo.bar: argument 1
services:
fake:
class: tests.ioc.service.Fake
arguments:
- "%foo.bar%"
kargs:
param: here a parameter
calls:
- [ set_ok, [ false ]]
- [ set_ok, [ true ], {arg2: "arg"} ]
foo:
class: tests.ioc.service.Foo
arguments: ["@fake", "#@weak_reference"]
kargs: {}
weak_reference:
class: tests.ioc.service.WeakReference
Then to use and access a service just do
.. code-block:: python
import ioc
container = ioc.build(['services.yml'])
foo = container.get('foo')