2016-04-20 14:25:40 +03:00
|
|
|
"""Dependency Injector example."""
|
2016-04-20 14:19:54 +03:00
|
|
|
|
2016-05-18 23:18:29 +03:00
|
|
|
from dependency_injector.injections import inject
|
2016-04-20 14:19:54 +03:00
|
|
|
|
2016-05-18 23:18:29 +03:00
|
|
|
from catalogs import Services
|
2016-04-20 14:19:54 +03:00
|
|
|
|
|
|
|
|
2016-05-18 23:18:29 +03:00
|
|
|
@inject(users_service=Services.users)
|
|
|
|
@inject(auth_service=Services.auth)
|
|
|
|
@inject(photos_service=Services.photos)
|
|
|
|
def main(login, password, photo, users_service, auth_service, photos_service):
|
2016-04-20 14:19:54 +03:00
|
|
|
"""Main function."""
|
|
|
|
user = users_service.get_user(login)
|
|
|
|
auth_service.authenticate(user, password)
|
2016-05-18 23:18:29 +03:00
|
|
|
photos_service.upload_photo(user['id'], photo)
|
2016-04-20 14:19:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-05-18 23:18:29 +03:00
|
|
|
main(login='user', password='secret', photo='photo.jpg')
|