I'm currently writing an internal abstraction layer in Python to help our developers talk to our internal data store without exposing them to the details.
Some parts of the abstraction layer require various connections and configuration (like paths, database connection, etc.) and since we would like to stay as flexible as possible we decided to abstract away the details. For this I have created a Configuration
class that has a bunch of unimplemented methods to get the details that are needed internally:
class Configuration:
def get_mongo_client(self):
"""
:returns: a :py:class:`pymongo.MongoClient` instance that should be used \
for talking to the database
"""
raise NotImplementedError()
# more getters...
Now, lets say I have a Users
class that requires a Configuration
instance internally. What would be the best way to make it available? I would really like to *avoid making Configuration
a parameter to __init__
. Are there any other ways to pass it around? Is there some kind of process local store that i could use?