mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
Update service names in services example miniapp
This commit is contained in:
parent
a62ddf8265
commit
9aee65057e
29
README.rst
29
README.rst
|
@ -134,16 +134,16 @@ several IoC containers for some example application:
|
|||
class Services(containers.DeclarativeContainer):
|
||||
"""IoC container of business service providers."""
|
||||
|
||||
users = providers.Factory(example.services.Users,
|
||||
users = providers.Factory(example.services.UsersService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database)
|
||||
|
||||
auth = providers.Factory(example.services.Auth,
|
||||
auth = providers.Factory(example.services.AuthService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
token_ttl=3600)
|
||||
|
||||
photos = providers.Factory(example.services.Photos,
|
||||
photos = providers.Factory(example.services.PhotosService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
s3=Platform.s3)
|
||||
|
@ -185,17 +185,18 @@ Next example demonstrates run of example application defined above:
|
|||
# s3 = boto.s3.connection.S3Connection(aws_access_key_id='KEY',
|
||||
# aws_secret_access_key='SECRET')
|
||||
#
|
||||
# example.main.main(uid=sys.argv[1],
|
||||
# password=sys.argv[2],
|
||||
# photo=sys.argv[3],
|
||||
# users_service=example.services.Users(logger=logger,
|
||||
# db=database),
|
||||
# auth_service=example.services.Auth(logger=logger,
|
||||
# db=database,
|
||||
# token_ttl=3600),
|
||||
# photos_service=example.services.Photos(logger=logger,
|
||||
# db=database,
|
||||
# s3=s3))
|
||||
# example.main.main(
|
||||
# uid=sys.argv[1],
|
||||
# password=sys.argv[2],
|
||||
# photo=sys.argv[3],
|
||||
# users_service=example.services.UsersService(logger=logger,
|
||||
# db=database),
|
||||
# auth_service=example.services.AuthService(logger=logger,
|
||||
# db=database,
|
||||
# token_ttl=3600),
|
||||
# photos_service=example.services.PhotosService(logger=logger,
|
||||
# db=database,
|
||||
# s3=s3))
|
||||
|
||||
Alternative definition styles of providers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -11,6 +11,7 @@ Development version
|
|||
-------------------
|
||||
.. - No features.
|
||||
- Add github badges to readme and docs index pages.
|
||||
- Update service names in services example miniapp.
|
||||
|
||||
2.2.8
|
||||
-----
|
||||
|
|
|
@ -27,16 +27,16 @@ class Platform(containers.DeclarativeContainer):
|
|||
class Services(containers.DeclarativeContainer):
|
||||
"""IoC container of business service providers."""
|
||||
|
||||
users = providers.Factory(example.services.Users,
|
||||
users = providers.Factory(example.services.UsersService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database)
|
||||
|
||||
auth = providers.Factory(example.services.Auth,
|
||||
auth = providers.Factory(example.services.AuthService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
token_ttl=3600)
|
||||
|
||||
photos = providers.Factory(example.services.Photos,
|
||||
photos = providers.Factory(example.services.PhotosService,
|
||||
logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
s3=Platform.s3)
|
||||
|
|
|
@ -32,16 +32,16 @@ class Platform(containers.DeclarativeContainer):
|
|||
class Services(containers.DeclarativeContainer):
|
||||
"""IoC container of business service providers."""
|
||||
|
||||
users = providers.Factory(example.services.Users) \
|
||||
users = providers.Factory(example.services.UsersService) \
|
||||
.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database)
|
||||
|
||||
auth = providers.Factory(example.services.Auth) \
|
||||
auth = providers.Factory(example.services.AuthService) \
|
||||
.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
token_ttl=3600)
|
||||
|
||||
photos = providers.Factory(example.services.Photos) \
|
||||
photos = providers.Factory(example.services.PhotosService) \
|
||||
.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
s3=Platform.s3)
|
||||
|
|
|
@ -32,16 +32,16 @@ class Platform(containers.DeclarativeContainer):
|
|||
class Services(containers.DeclarativeContainer):
|
||||
"""IoC container of business service providers."""
|
||||
|
||||
users = providers.Factory(example.services.Users)
|
||||
users = providers.Factory(example.services.UsersService)
|
||||
users.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database)
|
||||
|
||||
auth = providers.Factory(example.services.Auth)
|
||||
auth = providers.Factory(example.services.AuthService)
|
||||
auth.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
token_ttl=3600)
|
||||
|
||||
photos = providers.Factory(example.services.Photos)
|
||||
photos = providers.Factory(example.services.PhotosService)
|
||||
photos.add_kwargs(logger=Platform.logger,
|
||||
db=Platform.database,
|
||||
s3=Platform.s3)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Example business services module."""
|
||||
|
||||
|
||||
class Users(object):
|
||||
class UsersService(object):
|
||||
"""Users service."""
|
||||
|
||||
def __init__(self, logger, db):
|
||||
|
@ -16,7 +16,7 @@ class Users(object):
|
|||
'password_hash': 'secret_hash'}
|
||||
|
||||
|
||||
class Auth(object):
|
||||
class AuthService(object):
|
||||
"""Auth service."""
|
||||
|
||||
def __init__(self, logger, db, token_ttl):
|
||||
|
@ -32,7 +32,7 @@ class Auth(object):
|
|||
user['uid'])
|
||||
|
||||
|
||||
class Photos(object):
|
||||
class PhotosService(object):
|
||||
"""Photos service."""
|
||||
|
||||
def __init__(self, logger, db, s3):
|
||||
|
|
|
@ -22,14 +22,15 @@ if __name__ == '__main__':
|
|||
# s3 = boto.s3.connection.S3Connection(aws_access_key_id='KEY',
|
||||
# aws_secret_access_key='SECRET')
|
||||
#
|
||||
# example.main.main(uid=sys.argv[1],
|
||||
# password=sys.argv[2],
|
||||
# photo=sys.argv[3],
|
||||
# users_service=example.services.Users(logger=logger,
|
||||
# db=database),
|
||||
# auth_service=example.services.Auth(logger=logger,
|
||||
# db=database,
|
||||
# token_ttl=3600),
|
||||
# photos_service=example.services.Photos(logger=logger,
|
||||
# db=database,
|
||||
# s3=s3))
|
||||
# example.main.main(
|
||||
# uid=sys.argv[1],
|
||||
# password=sys.argv[2],
|
||||
# photo=sys.argv[3],
|
||||
# users_service=example.services.UsersService(logger=logger,
|
||||
# db=database),
|
||||
# auth_service=example.services.AuthService(logger=logger,
|
||||
# db=database,
|
||||
# token_ttl=3600),
|
||||
# photos_service=example.services.PhotosService(logger=logger,
|
||||
# db=database,
|
||||
# s3=s3))
|
||||
|
|
Loading…
Reference in New Issue
Block a user