Skip to content

Commit

Permalink
Merge pull request #105 from ynput/enhancement/prepare-entity-hub-for…
Browse files Browse the repository at this point in the history
…-new-folder-paths

Prepare entity hub for folder paths starting with slash
  • Loading branch information
iLLiCiTiT authored Oct 30, 2023
2 parents cff2524 + ffabd74 commit d4894b4
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions ayon_api/entity_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ def __init__(
):
if not connection:
connection = get_server_api_connection()
major, minor, _, _, _ = connection.server_version_tuple
path_start_with_slash = True
if (major, minor) < (0, 6):
path_start_with_slash = False

self._connection = connection
self._path_start_with_slash = path_start_with_slash

self._project_name = project_name
self._entities_by_id = {}
Expand All @@ -65,6 +71,18 @@ def allow_data_changes(self):

return self._allow_data_changes

@property
def path_start_with_slash(self):
"""Folder path should start with slash.
This changed in 0.6.x server version.
Returns:
bool: Path starts with slash.
"""

return self._path_start_with_slash

@property
def project_name(self):
"""Project name which is maintained by hub.
Expand Down Expand Up @@ -2419,10 +2437,13 @@ def get_path(self, dynamic_value=True):

if self._path is None:
parent = self.parent
path = self.name
if parent.entity_type == "folder":
parent_path = parent.path
path = "/".join([parent_path, path])
path = "/".join([parent_path, self.name])
elif self._entity_hub.path_start_with_slash:
path = "/{}".format(self.name)
else:
path = self.name
self._path = path
return self._path

Expand Down

0 comments on commit d4894b4

Please sign in to comment.