mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-09 15:42:23 +03:00
Update services example with new containers
This commit is contained in:
parent
97d1dab00a
commit
7206b4dbb8
|
@ -4,12 +4,12 @@ import sqlite3
|
||||||
import boto.s3.connection
|
import boto.s3.connection
|
||||||
import example.services
|
import example.services
|
||||||
|
|
||||||
from dependency_injector import catalogs
|
from dependency_injector import containers
|
||||||
from dependency_injector import providers
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
class Platform(catalogs.DeclarativeCatalog):
|
class Platform(containers.DeclarativeContainer):
|
||||||
"""Catalog of platform service providers."""
|
"""Container of platform service providers."""
|
||||||
|
|
||||||
database = providers.Singleton(sqlite3.connect, ':memory:')
|
database = providers.Singleton(sqlite3.connect, ':memory:')
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ class Platform(catalogs.DeclarativeCatalog):
|
||||||
aws_secret_access_key='SECRET')
|
aws_secret_access_key='SECRET')
|
||||||
|
|
||||||
|
|
||||||
class Services(catalogs.DeclarativeCatalog):
|
class Services(containers.DeclarativeContainer):
|
||||||
"""Catalog of business service providers."""
|
"""Container of business service providers."""
|
||||||
|
|
||||||
users = providers.Factory(example.services.Users,
|
users = providers.Factory(example.services.Users,
|
||||||
db=Platform.database)
|
db=Platform.database)
|
|
@ -7,12 +7,12 @@ import sqlite3
|
||||||
import boto.s3.connection
|
import boto.s3.connection
|
||||||
import example.services
|
import example.services
|
||||||
|
|
||||||
from dependency_injector import catalogs
|
from dependency_injector import containers
|
||||||
from dependency_injector import providers
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
class Platform(catalogs.DeclarativeCatalog):
|
class Platform(containers.DeclarativeContainer):
|
||||||
"""Catalog of platform service providers."""
|
"""Container of platform service providers."""
|
||||||
|
|
||||||
database = providers.Singleton(sqlite3.connect) \
|
database = providers.Singleton(sqlite3.connect) \
|
||||||
.add_args(':memory:')
|
.add_args(':memory:')
|
||||||
|
@ -22,8 +22,8 @@ class Platform(catalogs.DeclarativeCatalog):
|
||||||
aws_secret_access_key='SECRET')
|
aws_secret_access_key='SECRET')
|
||||||
|
|
||||||
|
|
||||||
class Services(catalogs.DeclarativeCatalog):
|
class Services(containers.DeclarativeContainer):
|
||||||
"""Catalog of business service providers."""
|
"""Container of business service providers."""
|
||||||
|
|
||||||
users = providers.Factory(example.services.Users) \
|
users = providers.Factory(example.services.Users) \
|
||||||
.add_kwargs(db=Platform.database)
|
.add_kwargs(db=Platform.database)
|
|
@ -7,12 +7,12 @@ import sqlite3
|
||||||
import boto.s3.connection
|
import boto.s3.connection
|
||||||
import example.services
|
import example.services
|
||||||
|
|
||||||
from dependency_injector import catalogs
|
from dependency_injector import containers
|
||||||
from dependency_injector import providers
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
class Platform(catalogs.DeclarativeCatalog):
|
class Platform(containers.DeclarativeContainer):
|
||||||
"""Catalog of platform service providers."""
|
"""Container of platform service providers."""
|
||||||
|
|
||||||
database = providers.Singleton(sqlite3.connect)
|
database = providers.Singleton(sqlite3.connect)
|
||||||
database.add_args(':memory:')
|
database.add_args(':memory:')
|
||||||
|
@ -22,8 +22,8 @@ class Platform(catalogs.DeclarativeCatalog):
|
||||||
aws_secret_access_key='SECRET')
|
aws_secret_access_key='SECRET')
|
||||||
|
|
||||||
|
|
||||||
class Services(catalogs.DeclarativeCatalog):
|
class Services(containers.DeclarativeContainer):
|
||||||
"""Catalog of business service providers."""
|
"""Container of business service providers."""
|
||||||
|
|
||||||
users = providers.Factory(example.services.Users)
|
users = providers.Factory(example.services.Users)
|
||||||
users.add_kwargs(db=Platform.database)
|
users.add_kwargs(db=Platform.database)
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from dependency_injector.injections import inject
|
from dependency_injector.injections import inject
|
||||||
|
|
||||||
from catalogs import Services
|
from containers import Services
|
||||||
|
|
||||||
|
|
||||||
@inject(users_service=Services.users)
|
@inject(users_service=Services.users)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user