From 39edeb43f3cfd0b0f83c0d76377311ef0dd8b668 Mon Sep 17 00:00:00 2001 From: Patrick Macdonald <4705216+reformstudios@users.noreply.github.com> Date: Mon, 14 Oct 2019 23:44:38 +0100 Subject: [PATCH 1/2] Adds "system_name" field to "shotgun" descriptor. Adding a "system_name" field to the "shotgun" descriptor allows for overriding the default behaviour in the "get_system_name" method which returns the wrong name for use in hook templates where the {engine} tag is used. eg, if a descriptor points to a toolkit bundle names "tk-houdini_release_v1.2.3", and a hook path is of the form "path: /some/path/to/{engine}/hook" then the {engine} field will be replaced by {entity_type}_{entity_id}, which will not point to the expected location of, for example, 'tl-houdini/hook' it will instead point to 'customNonProjectEntity01_104/hook'. Adding an optional field to allow the user to set the "system_name" manually allows the default behaviour to be overridden where required without breaking existing expected behaviour. This should resolve the issues raised on the community site on pages :- - https://community.shotgunsoftware.com/t/possible-hook-path-bug/3365 - https://community.shotgunsoftware.com/t/names-for-apps-frameworks-specified-via-shotgun-descriptors/2989 --- python/tank/descriptor/io_descriptor/shotgun_entity.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/tank/descriptor/io_descriptor/shotgun_entity.py b/python/tank/descriptor/io_descriptor/shotgun_entity.py index 82505b1d6f..3c29b5280d 100644 --- a/python/tank/descriptor/io_descriptor/shotgun_entity.py +++ b/python/tank/descriptor/io_descriptor/shotgun_entity.py @@ -87,7 +87,7 @@ def __init__(self, descriptor_dict, sg_connection, bundle_type): self._validate_descriptor( descriptor_dict, required=["type", "entity_type", "id", "version", "field"], - optional=[] + optional=["system_name"] ) # convert to int @@ -125,6 +125,7 @@ def __init__(self, descriptor_dict, sg_connection, bundle_type): self._bundle_type = bundle_type self._entity_type = descriptor_dict.get("entity_type") self._field = descriptor_dict.get("field") + self._system_name = descriptor_dict.get("system_name") # ensure version is an int if specified try: @@ -172,8 +173,11 @@ def get_system_name(self): name = self._name elif self._mode == self._MODE_ID_BASED: - # e.g. 'PipelineConfiguration_1234' - name = "%s_%s" % (self._entity_type, self._entity_id) + if self._system_name: + name = self._system_name + else: + # e.g. 'PipelineConfiguration_1234' + name = "%s_%s" % (self._entity_type, self._entity_id) return filesystem.create_valid_filename(name) From eacb38857ccd8856591c4d4dff63c15a3204f913 Mon Sep 17 00:00:00 2001 From: Patrick Macdonald <4705216+reformstudios@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:15:09 +0100 Subject: [PATCH 2/2] lint --- python/tank/descriptor/io_descriptor/shotgun_entity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tank/descriptor/io_descriptor/shotgun_entity.py b/python/tank/descriptor/io_descriptor/shotgun_entity.py index 09af384b06..ceac702c91 100644 --- a/python/tank/descriptor/io_descriptor/shotgun_entity.py +++ b/python/tank/descriptor/io_descriptor/shotgun_entity.py @@ -89,7 +89,7 @@ def __init__(self, descriptor_dict, sg_connection, bundle_type): self._validate_descriptor( descriptor_dict, required=["type", "entity_type", "id", "version", "field"], - optional=["system_name"] + optional=["system_name"], ) # convert to int