Skip to content

Commit 9a634f8

Browse files
committed
Merge branch 'release/3.9.0' into master
2 parents bd38c23 + b767387 commit 9a634f8

File tree

27 files changed

+6142
-4159
lines changed

27 files changed

+6142
-4159
lines changed

docs/examples/bundles_miniapp.rst

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
Bundles mini application example
2+
--------------------------------
3+
4+
.. currentmodule:: dependency_injector.containers
5+
6+
"Bundles" is an example mini application that is intented to demonstrate the
7+
power of dependency injection for creation of re-usable application components
8+
("bundles") with 100% transparency of their dependencies.
9+
10+
Example application
11+
~~~~~~~~~~~~~~~~~~~
12+
13+
"Bundles" mini application has next structure:
14+
15+
.. code-block:: bash
16+
17+
bundles/
18+
bundles/ <-- Bundles package
19+
photos/ <-- Photos bundle
20+
__init__.py <-- Photos bundle dependency injection container
21+
entities.py
22+
repositories.py
23+
users/ <-- Users bundle
24+
__init__.py <-- Users bundle dependency injection container
25+
entities.py
26+
repositories.py
27+
run.py <-- Entrypoint
28+
29+
30+
IoC containers
31+
~~~~~~~~~~~~~~
32+
33+
Next two listings show :py:class:`DeclarativeContainer`'s for "users" and
34+
"photos" bundles.
35+
36+
Listing of ``bundeles/users/__init__.py``:
37+
38+
.. literalinclude:: ../../examples/miniapps/bundles/bundles/users/__init__.py
39+
:language: python
40+
:linenos:
41+
42+
.. note::
43+
44+
- ``Users`` container has dependency on database.
45+
46+
Listing of ``bundeles/photos/__init__.py``:
47+
48+
.. literalinclude:: ../../examples/miniapps/bundles/bundles/photos/__init__.py
49+
:language: python
50+
:linenos:
51+
52+
.. note::
53+
54+
- ``Photos`` container has dependencies on database and file storage.
55+
56+
Run application
57+
~~~~~~~~~~~~~~~
58+
59+
Finally, both "bundles" are initialized by providing needed dependencies.
60+
Initialization of dependencies happens right in the runtime, not earlier.
61+
Generally, it means, that any part of any bundle could be overridden on the
62+
fly.
63+
64+
Listing of ``run.py``:
65+
66+
.. literalinclude:: ../../examples/miniapps/bundles/run.py
67+
:language: python
68+
:linenos:
69+
70+
Links
71+
~~~~~
72+
73+
+ `Dependency Injector <https://github.com/ets-labs/python-dependency-injector/>`_
74+
+ `Full example sources <https://github.com/ets-labs/python-dependency-injector/tree/master/examples/miniapps/bundles>`_
75+
76+
77+
.. disqus::

docs/examples/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ and powered by *Dependency Injector* framework.
1717

1818
movie_lister
1919
services_miniapp
20+
bundles_miniapp
41.7 KB
Loading
-41.3 KB
Binary file not shown.

docs/main/changelog.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ that were made in every particular version.
77
From version 0.7.6 *Dependency Injector* framework strictly
88
follows `Semantic versioning`_
99

10+
3.9.0
11+
-----
12+
- Change initialization of declarative container, so it accepts overriding
13+
providers as keyword arguments -
14+
``DeclarativeContainer(**overriding_providers)``.
15+
- Add method to dynamic catalog for setting groups of providers -
16+
``DynamicContainer.set_providers(**providers)``.
17+
- Add method to dynamic catalog for overriding groups of providers -
18+
``DynamicContainer.set_providers(**overriding_providers)``.
19+
- Rename ``ExternalDependency`` provider to ``Dependency``.
20+
- Add default value for ``instance_of`` argument of ``Dependency`` provider -
21+
``Dependency(instance_of=object)``.
22+
- Fix bug when copying ``Configuration`` provider.
23+
- Regenerate C sources using Cython 0.27.3.
24+
- Add "bundles" example miniapp.
25+
26+
1027
3.8.2
1128
-----
1229
- Fix padding problem in code samples in docs (part 2).

docs/providers/external_dependency.rst renamed to docs/providers/dependency.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
External dependency providers
2-
-----------------------------
1+
Dependency providers
2+
--------------------
33

44
.. currentmodule:: dependency_injector.providers
55

6-
:py:class:`ExternalDependency` provider can be useful for development of
6+
:py:class:`Dependency` provider can be useful for development of
77
self-sufficient libraries / modules / applications that have required external
88
dependencies.
99

@@ -35,11 +35,10 @@ Example:
3535
Instead of this, ``UsersService`` has external dependency, that has to
3636
be satisfied by cleint's code, out of library's scope.
3737

38-
.. image:: /images/providers/external_dependency.png
38+
.. image:: /images/providers/dependency.png
3939

40-
.. literalinclude:: ../../examples/providers/external_dependency.py
40+
.. literalinclude:: ../../examples/providers/dependency.py
4141
:language: python
4242
:linenos:
4343

44-
4544
.. disqus::

docs/providers/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Providers package API docs - :py:mod:`dependency_injector.providers`
2121
singleton
2222
callable
2323
object
24-
external_dependency
24+
dependency
2525
overriding
2626
custom
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Dependency Injector Bundles example
2+
===================================
3+
4+
Instructions for running
5+
6+
.. code-block:: bash
7+
8+
python run.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Bundles package."""
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Photos bundle."""
2+
3+
from dependency_injector import containers
4+
from dependency_injector import providers
5+
6+
from . import entities
7+
from . import repositories
8+
9+
10+
class Photos(containers.DeclarativeContainer):
11+
"""Photos bundle container."""
12+
13+
database = providers.Dependency()
14+
file_storage = providers.Dependency()
15+
16+
photo = providers.Factory(entities.Photo)
17+
photo_repository = providers.Singleton(repositories.PhotoRepository,
18+
object_factory=photo.provider,
19+
fs=file_storage,
20+
db=database)

0 commit comments

Comments
 (0)