Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

How to use one service from another? #32

Open
dukedougal opened this issue Aug 4, 2014 · 1 comment
Open

How to use one service from another? #32

dukedougal opened this issue Aug 4, 2014 · 1 comment

Comments

@dukedougal
Copy link

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

@mattupstate
Copy link
Owner

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....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants