-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore: Add 'parents' to folder template data #778
Chore: Add 'parents' to folder template data #778
Conversation
Hmm - yeah, hmm.. this is bound to give issues. If anyone would use e.g. Can we re-iterate why |
I wonder if we could use for that reason optional decoration |
BTW this seems to be very good case for unittesting. |
@@ -407,8 +407,10 @@ def _fill_folder_data(self, instance, project_entity, anatomy_data): | |||
anatomy_data["hierarchy"] = hierarchy | |||
|
|||
parent_name = project_entity["name"] | |||
parents = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems valid to always have parents filled with at least project, right? Since we are converting parent_name from project name in case there is no parent at all it would be fair to also add it. In this case {folder[parent[-1]]}
would always work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't think project should be there. But the use-case is that they would like to be able to use {folder[parents][0]}
and {folder[parents][1]}
not really -1
. For -1
you can use {parent}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think project name should be there too - the reason why is that you should be explicit enough if you want to have project name there (and you can access it with another key).
So if you have asset folder directly under project, {folder[parents][0]}
will not work if I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you have asset folder directly under project, {folder[parents][0]} will not work if I am not mistaken.
Yes, it won't.
Ah - if that works I must admit that's fine then I suppose. |
So we should add to the testing notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I didn't think of is output of used values which right now in Another issue might be negative index |
Now it does work as expected. It is possible to use lists in values. But negative indexes on list can cause issues when the tempalte is used out of Or not? Not sure, at the end if anyone is willing to use the template afterwards he still have to use |
…plate-keys # Conflicts: # client/ayon_core/plugins/publish/collect_anatomy_instance_data.py
I don't actually think we state anywhere that templates are compatible with python formatting. So if we say that Auto-converting it to proper index is ofc the way too. If I would have to choose, I'd say -> If we have interactive validator for templates in the Settings, then not supporting |
Changelog Description
Add
"parents"
subkey to folder template data.Additional info
This does allow to use indexing of parent names in templates. I'm not sure if this is correct approach, but it is the best I could think of. This change does not consider that someone would like to use e.g. labels instead of names in future, hopefully that won't happen.
There is no safeguard for using the list, so if the parent index is not available it will just crash. That might cause issues in specific logic which is filling template paths and does not count on this.
Testing notes:
{folder[parents[0]]}
in templates.Resolves #867