2020-09-01 23:04:48 +03:00
|
|
|
"""`Factory` provider example."""
|
2015-06-05 11:29:36 +03:00
|
|
|
|
2020-09-03 23:46:03 +03:00
|
|
|
from dependency_injector import containers, providers
|
2016-06-08 16:54:47 +03:00
|
|
|
|
2015-06-05 11:29:36 +03:00
|
|
|
|
2020-09-01 04:26:21 +03:00
|
|
|
class User:
|
|
|
|
...
|
2015-06-05 11:29:36 +03:00
|
|
|
|
|
|
|
|
2020-09-03 23:46:03 +03:00
|
|
|
class Container(containers.DeclarativeContainer):
|
|
|
|
|
|
|
|
user_factory = providers.Factory(User)
|
2015-06-05 11:29:36 +03:00
|
|
|
|
2020-09-01 04:26:21 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-09-03 23:46:03 +03:00
|
|
|
container = Container()
|
|
|
|
|
|
|
|
user1 = container.user_factory()
|
|
|
|
user2 = container.user_factory()
|