2016-05-22 16:02:10 +03:00
|
|
|
"""Dependency Injector @inject decorator example."""
|
2016-04-20 14:19:54 +03:00
|
|
|
|
2016-06-03 18:05:47 +03:00
|
|
|
import application
|
|
|
|
import dependency_injector.injections as injections
|
2016-04-20 14:19:54 +03:00
|
|
|
|
|
|
|
|
2016-06-03 18:05:47 +03:00
|
|
|
@injections.inject(users_service=application.Services.users)
|
|
|
|
@injections.inject(auth_service=application.Services.auth)
|
|
|
|
@injections.inject(photos_service=application.Services.photos)
|
2016-05-22 16:02:10 +03:00
|
|
|
def main(users_service, auth_service, photos_service):
|
2016-04-20 14:19:54 +03:00
|
|
|
"""Main function."""
|
2016-05-22 16:02:10 +03:00
|
|
|
user = users_service.get_user('user')
|
|
|
|
auth_service.authenticate(user, 'secret')
|
|
|
|
photos_service.upload_photo(user['id'], 'photo.jpg')
|
2016-04-20 14:19:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2016-05-22 16:02:10 +03:00
|
|
|
main()
|