From e63735757ded14e71d9c02ca274c221f73d4f467 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 5 Oct 2022 10:44:38 +0200 Subject: [PATCH] get current context from host in controller --- openpype/tools/publisher/control.py | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/openpype/tools/publisher/control.py b/openpype/tools/publisher/control.py index 522ebcc50d..afcf765cfd 100644 --- a/openpype/tools/publisher/control.py +++ b/openpype/tools/publisher/control.py @@ -118,7 +118,7 @@ class AssetDocsCache: def _query(self): if self._asset_docs is None: - project_name = self.dbcon.active_project() + project_name = self._controller.project_name asset_docs = get_assets( project_name, fields=self.projection.keys() ) @@ -419,8 +419,33 @@ class PublisherController: @property def project_name(self): - """Current project context.""" - return self.dbcon.Session["AVALON_PROJECT"] + """Current project context defined by host. + + Returns: + str: Project name. + """ + + return self.host.get_current_context()["project_name"] + + @property + def current_asset_name(self): + """Current context asset name defined by host. + + Returns: + Union[str, None]: Asset name or None if asset is not set. + """ + + return self.host.get_current_context()["asset_name"] + + @property + def current_task_name(self): + """Current context task name defined by host. + + Returns: + Union[str, None]: Task name or None if task is not set. + """ + + return self.host.get_current_context()["task_name"] @property def dbcon(self):