Update service names in services example miniapp

This commit is contained in:
Roman Mogilatov 2016-10-19 15:25:19 +03:00
parent a62ddf8265
commit 9aee65057e
7 changed files with 40 additions and 37 deletions

View File

@ -134,16 +134,16 @@ several IoC containers for some example application:
class Services(containers.DeclarativeContainer): class Services(containers.DeclarativeContainer):
"""IoC container of business service providers.""" """IoC container of business service providers."""
users = providers.Factory(example.services.Users, users = providers.Factory(example.services.UsersService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database) db=Platform.database)
auth = providers.Factory(example.services.Auth, auth = providers.Factory(example.services.AuthService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database, db=Platform.database,
token_ttl=3600) token_ttl=3600)
photos = providers.Factory(example.services.Photos, photos = providers.Factory(example.services.PhotosService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database, db=Platform.database,
s3=Platform.s3) 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', # s3 = boto.s3.connection.S3Connection(aws_access_key_id='KEY',
# aws_secret_access_key='SECRET') # aws_secret_access_key='SECRET')
# #
# example.main.main(uid=sys.argv[1], # example.main.main(
# password=sys.argv[2], # uid=sys.argv[1],
# photo=sys.argv[3], # password=sys.argv[2],
# users_service=example.services.Users(logger=logger, # photo=sys.argv[3],
# db=database), # users_service=example.services.UsersService(logger=logger,
# auth_service=example.services.Auth(logger=logger, # db=database),
# db=database, # auth_service=example.services.AuthService(logger=logger,
# token_ttl=3600), # db=database,
# photos_service=example.services.Photos(logger=logger, # token_ttl=3600),
# db=database, # photos_service=example.services.PhotosService(logger=logger,
# s3=s3)) # db=database,
# s3=s3))
Alternative definition styles of providers Alternative definition styles of providers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -11,6 +11,7 @@ Development version
------------------- -------------------
.. - No features. .. - No features.
- Add github badges to readme and docs index pages. - Add github badges to readme and docs index pages.
- Update service names in services example miniapp.
2.2.8 2.2.8
----- -----

View File

@ -27,16 +27,16 @@ class Platform(containers.DeclarativeContainer):
class Services(containers.DeclarativeContainer): class Services(containers.DeclarativeContainer):
"""IoC container of business service providers.""" """IoC container of business service providers."""
users = providers.Factory(example.services.Users, users = providers.Factory(example.services.UsersService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database) db=Platform.database)
auth = providers.Factory(example.services.Auth, auth = providers.Factory(example.services.AuthService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database, db=Platform.database,
token_ttl=3600) token_ttl=3600)
photos = providers.Factory(example.services.Photos, photos = providers.Factory(example.services.PhotosService,
logger=Platform.logger, logger=Platform.logger,
db=Platform.database, db=Platform.database,
s3=Platform.s3) s3=Platform.s3)

View File

@ -32,16 +32,16 @@ class Platform(containers.DeclarativeContainer):
class Services(containers.DeclarativeContainer): class Services(containers.DeclarativeContainer):
"""IoC container of business service providers.""" """IoC container of business service providers."""
users = providers.Factory(example.services.Users) \ users = providers.Factory(example.services.UsersService) \
.add_kwargs(logger=Platform.logger, .add_kwargs(logger=Platform.logger,
db=Platform.database) db=Platform.database)
auth = providers.Factory(example.services.Auth) \ auth = providers.Factory(example.services.AuthService) \
.add_kwargs(logger=Platform.logger, .add_kwargs(logger=Platform.logger,
db=Platform.database, db=Platform.database,
token_ttl=3600) token_ttl=3600)
photos = providers.Factory(example.services.Photos) \ photos = providers.Factory(example.services.PhotosService) \
.add_kwargs(logger=Platform.logger, .add_kwargs(logger=Platform.logger,
db=Platform.database, db=Platform.database,
s3=Platform.s3) s3=Platform.s3)

View File

@ -32,16 +32,16 @@ class Platform(containers.DeclarativeContainer):
class Services(containers.DeclarativeContainer): class Services(containers.DeclarativeContainer):
"""IoC container of business service providers.""" """IoC container of business service providers."""
users = providers.Factory(example.services.Users) users = providers.Factory(example.services.UsersService)
users.add_kwargs(logger=Platform.logger, users.add_kwargs(logger=Platform.logger,
db=Platform.database) db=Platform.database)
auth = providers.Factory(example.services.Auth) auth = providers.Factory(example.services.AuthService)
auth.add_kwargs(logger=Platform.logger, auth.add_kwargs(logger=Platform.logger,
db=Platform.database, db=Platform.database,
token_ttl=3600) token_ttl=3600)
photos = providers.Factory(example.services.Photos) photos = providers.Factory(example.services.PhotosService)
photos.add_kwargs(logger=Platform.logger, photos.add_kwargs(logger=Platform.logger,
db=Platform.database, db=Platform.database,
s3=Platform.s3) s3=Platform.s3)

View File

@ -1,7 +1,7 @@
"""Example business services module.""" """Example business services module."""
class Users(object): class UsersService(object):
"""Users service.""" """Users service."""
def __init__(self, logger, db): def __init__(self, logger, db):
@ -16,7 +16,7 @@ class Users(object):
'password_hash': 'secret_hash'} 'password_hash': 'secret_hash'}
class Auth(object): class AuthService(object):
"""Auth service.""" """Auth service."""
def __init__(self, logger, db, token_ttl): def __init__(self, logger, db, token_ttl):
@ -32,7 +32,7 @@ class Auth(object):
user['uid']) user['uid'])
class Photos(object): class PhotosService(object):
"""Photos service.""" """Photos service."""
def __init__(self, logger, db, s3): def __init__(self, logger, db, s3):

View File

@ -22,14 +22,15 @@ if __name__ == '__main__':
# s3 = boto.s3.connection.S3Connection(aws_access_key_id='KEY', # s3 = boto.s3.connection.S3Connection(aws_access_key_id='KEY',
# aws_secret_access_key='SECRET') # aws_secret_access_key='SECRET')
# #
# example.main.main(uid=sys.argv[1], # example.main.main(
# password=sys.argv[2], # uid=sys.argv[1],
# photo=sys.argv[3], # password=sys.argv[2],
# users_service=example.services.Users(logger=logger, # photo=sys.argv[3],
# db=database), # users_service=example.services.UsersService(logger=logger,
# auth_service=example.services.Auth(logger=logger, # db=database),
# db=database, # auth_service=example.services.AuthService(logger=logger,
# token_ttl=3600), # db=database,
# photos_service=example.services.Photos(logger=logger, # token_ttl=3600),
# db=database, # photos_service=example.services.PhotosService(logger=logger,
# s3=s3)) # db=database,
# s3=s3))