default mongo url is accessible with method

This commit is contained in:
iLLiCiTiT 2021-03-18 10:18:16 +01:00
parent f2ecff2688
commit 355872938b

View file

@ -137,10 +137,14 @@ class PypeMongoConnection:
mongo_clients = {}
log = logging.getLogger("PypeMongoConnection")
@staticmethod
def get_default_mongo_url():
return os.environ["PYPE_MONGO"]
@classmethod
def get_mongo_client(cls, mongo_url=None):
if mongo_url is None:
mongo_url = os.environ["PYPE_MONGO"]
mongo_url = cls.get_default_mongo_url()
connection = cls.mongo_clients.get(mongo_url)
if connection: