mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 01:47:36 +03:00 
			
		
		
		
	* Add bootstrap and remove created at from ghnav-flask app * Update readme * Add logo to the docs * Update key features description * Update README * Change headers of API docs * Add alabaster theme config * Update docs index * Add tutorials section * Update what is DI page * Update DI in Python page * Update tutorials index page * Update provider docs * Update container docs * Update examples docs
		
			
				
	
	
		
			29 lines
		
	
	
		
			1016 B
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			1016 B
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
Dynamic containers
 | 
						|
------------------
 | 
						|
 | 
						|
.. currentmodule:: dependency_injector.containers
 | 
						|
 | 
						|
:py:class:`DynamicContainer` is an inversion of control container with dynamic 
 | 
						|
structure. It should cover most of the cases when list of providers that 
 | 
						|
would be included in container is non-deterministic and depends on 
 | 
						|
application's flow or its configuration (container's structure could be 
 | 
						|
determined just after application will be started and will do some initial 
 | 
						|
work, like parsing list of container's providers from the configuration).
 | 
						|
 | 
						|
While :py:class:`DeclarativeContainer` acts on class-level, 
 | 
						|
:py:class:`DynamicContainer` does the same on instance-level.
 | 
						|
 | 
						|
Here is an simple example of defining dynamic container with several factories:
 | 
						|
 | 
						|
.. literalinclude:: ../../examples/containers/dynamic.py
 | 
						|
   :language: python
 | 
						|
 | 
						|
Next example demonstrates creation of dynamic container based on some 
 | 
						|
configuration:
 | 
						|
 | 
						|
.. literalinclude:: ../../examples/containers/dynamic_runtime_creation.py
 | 
						|
   :language: python
 | 
						|
 | 
						|
 | 
						|
.. disqus::
 |