mattupstate/overholt

How to use one service from another?

dukedougal opened this issue · 1 comments

Hi Matt,

In Overholt, the way I understand it, instances of each service are loaded into the "services.py". To use the services, I then import the instance that I want to use from services.py.

This outcome of this appears to be that I cannot use one service from another I suspect due to circular imports. Is my understanding correct?

If so, and if I cannot import one service from another, what is the correct way to use one service from another? i.e. use the "user" object from "store"?

thanks

You can "compose" another service that combines the two. For instance:

class OverholtService(object):
    def __init__(self):
        self.products = ProductsService()
        self.stores = StoresService()
        self.users = UsersService()

    def method_that_combines_both_services(self):
        self.products...
        self.users....