Jump to content

Query for all available options in a custom attribute


kim-a

Recommended Posts

In our Ftrack installation, we have defined a custom attribute at the project level--let's call it "locations". I would like to create a function that allows users to add an additional location to a project after querying that the provided argument is indeed an available option in the collection of locations. I can't find an example of this kind of query; I just need to know whether this is something attached to Session or somewhere else.

So let's say locations = {'Uptown': 'uptown', 'Downtown': 'downtown', 'Midtown': 'midtown'} (in settings it's an Enumerator that seems to be represented as a dictionary)

Quote

def addLocation(project, site):

    # get project using proprietary wrapper here

    allSites = session['custom_attributes']['locations']

    if site not in allSites:

        print "That site is not valid."

        return

   else:

       # add location to project here     

We created our own wrappers for some of several of the Ftrack queries, so I decided not to include that code. The part in bold is what I'm getting at... is this the way to access it? I thought this might be the way because the documentation says: "The custom attributes available on entities are cached on the Session." It isn't working when I run unit tests.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...