It’s annoying to have to have two different definitions that are nearly the same. Is there a way to define just one token but have it contextually switch?
I’ve seen the use of the alias attribute in the documentation but I’m not sure if it would work in this case.
I think that you can resolve this, by looking at the context_additional_entities.py core hook. In case the “Entity” of your context is a Shot, you could add it’s sequence to the “additional_entities” list.
This way you can get rid of your first key-definition (Shot, sg_sequence.Sequence…).
It’s been a while since I used this myself, but I looked it up and found an example.
You may implement it like like this:
class ContextAdditionalEntities(Hook):
def execute(self, **kwargs):
val = {"entity_types_in_path": [], "entity_fields_on_task": ["entity.Shot.sg_sequence.Sequence"]}
return val
This should add a Sequence entity to your contexts in Shotgun Desktop if you have a Shot context. And that hopefully makes your templates resolvable using sequence_number instead of shot_sequence_number.