From f4185e6841b262f5df8efd90bb8e650a36533327 Mon Sep 17 00:00:00 2001 From: Alexandru Pisarenco Date: Mon, 27 Jun 2022 23:50:51 +0200 Subject: [PATCH 1/2] Fix and clean up imports. ResolveOptions is being initialized --- objectModel/Python/cdm/objectmodel/cdm_object_def.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/objectModel/Python/cdm/objectmodel/cdm_object_def.py b/objectModel/Python/cdm/objectmodel/cdm_object_def.py index fdb9e9535e..8b8e96e9e4 100644 --- a/objectModel/Python/cdm/objectmodel/cdm_object_def.py +++ b/objectModel/Python/cdm/objectmodel/cdm_object_def.py @@ -4,16 +4,16 @@ from abc import abstractmethod from typing import Optional, TYPE_CHECKING -from cdm.enums import CdmObjectType +from cdm.utilities import ResolveOptions from .cdm_object import CdmObject from .cdm_object_ref import CdmObjectReference from .cdm_trait_collection import CdmTraitCollection if TYPE_CHECKING: - from cdm.objectmodel import CdmCorpusContext, CdmTraitDefinition, CdmTraitReference + from cdm.objectmodel import CdmCorpusContext from cdm.resolvedmodel import ResolvedTraitSetBuilder - from cdm.utilities import ResolveOptions, VisitCallback + from cdm.utilities import VisitCallback class CdmObjectDefinition(CdmObject): From 8184d26d160b949f7f39850cae5f8e13db6f328a Mon Sep 17 00:00:00 2001 From: Alexandru Pisarenco Date: Mon, 27 Jun 2022 23:51:29 +0200 Subject: [PATCH 2/2] Resolve deprecation warnings with obj.namespace --- objectModel/Python/cdm/storage/storage_manager.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/objectModel/Python/cdm/storage/storage_manager.py b/objectModel/Python/cdm/storage/storage_manager.py index 198d0234a9..4db8031680 100644 --- a/objectModel/Python/cdm/storage/storage_manager.py +++ b/objectModel/Python/cdm/storage/storage_manager.py @@ -191,12 +191,14 @@ def create_absolute_corpus_path(self, object_path: str, obj: 'CdmObject' = None) prefix = None namespace_from_obj = None - if obj and hasattr(obj, 'namespace') and hasattr(obj, 'folder_path'): - prefix = obj._folder_path - namespace_from_obj = obj._namespace - elif obj and obj.in_document: - prefix = obj.in_document._folder_path - namespace_from_obj = obj.in_document._namespace + if obj: + obj_doc = getattr(obj, "owner", obj) + if hasattr(obj_doc, 'namespace') and hasattr(obj_doc, 'folder_path'): + prefix = obj_doc.folder_path + namespace_from_obj = obj_doc.namespace + elif obj.in_document: + prefix = obj.in_document._folder_path + namespace_from_obj = obj.in_document._namespace if prefix and self._contains_unsupported_path_format(prefix): # Already called status_rpt when checking for unsupported path format.