OP-2951 - refactored to use AvalonMongoDB

This commit is contained in:
Petr Kalis 2022-04-20 12:29:02 +02:00
parent fc4f7ed5d9
commit eb1f72fccd

View file

@ -1990,13 +1990,14 @@ def get_linked_ids_for_representations(project_name, repre_ids, dbcon=None,
Returns: Returns:
(list) of ObjectId - linked representations (list) of ObjectId - linked representations
""" """
# Create new dbcon if not passed and use passed project name
if not dbcon: if not dbcon:
log.debug("Using `avalon.io` for query.") from avalon.api import AvalonMongoDB
dbcon = avalon.io dbcon = AvalonMongoDB()
# Make sure is installed dbcon.Session["AVALON_PROJECT"] = project_name
dbcon.install() # Validate that passed dbcon has same project
elif dbcon.Session["AVALON_PROJECT"] != project_name:
dbcon.Session["AVALON_PROJECT"] = project_name raise ValueError("Passed connection does not have right project")
if not isinstance(repre_ids, list): if not isinstance(repre_ids, list):
repre_ids = [repre_ids] repre_ids = [repre_ids]