| Home | Trees | Indices | Help |
|---|
|
|
Dependency injection framework.
The framework provides lously coupled passing of dependencies from providers to the objects that require them.
Dependencies are identified by keys, that are valid Python identifiers. Dependencies are provided via accessor functions, that in general will be called whenever they are needed.
|
|||
| DependencyError | |||
| InjectionRegistry | |||
|
dependency Data descriptor that provides a given dependency looking as an attribute. |
|||
| Injector | |||
| RegistryInjector | |||
| InjectionFactory | |||
|
|||
|
|||
|
|||
|
|||
|
|||
_global_injection_registry = InjectionRegistry()
|
|||
__package__ =
|
|||
|
|||
Decorates a method where dependencies are passed as keyword parameters. Dependencies are specified as keywords with an optional accessor function or None if required. Dependencies can be injected or passed directly as keyword parameters. Example:
class HttpServer(object):
@depends(http_port = const(80))
def listen(http_port = None):
print "Listening on", http_port
server = HttpServer()
server.listen()
server.listen(http_port = 8000)
with inject(http_port = const(8000)).everywhere():
server.listen()
Produces the output: Listening on port 80 Listening on port 8000 Listening on port 8000 |
Inject returns a InjectorFactory that can generate Injectors to inject the provided keys at different levels. The values to inject are specified as keyword parameters mapping keys to given nullary callables that will be used to access the dependency when needed. |
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Wed Mar 6 18:53:31 2013 | http://epydoc.sourceforge.net |