ftrack Python API
latest
  • Introduction
  • Installing
  • Tutorial
  • Understanding sessions
  • Working with entities
  • Querying
  • Handling events
  • Caching
  • Locations
  • Usage examples
    • Working with projects
    • Working with components
    • Using review sessions
    • Using metadata
    • Using custom attributes
    • Using custom attributes links
    • Managing custom attributes
    • Using link attributes
    • Using scopes
    • Managing jobs
    • Using notes
    • Using lists
    • Using timers
    • Working with assignments and allocations
    • Working with thumbnails
    • Encoding media
    • Using entity links
    • Publishing for web review
    • Publishing versions
    • Working with user security roles
    • Working with Task Templates
    • Sync users with LDAP
    • Invite user
    • Creating workflow schemas
  • API Reference
  • Event list
  • Environment variables
  • Security and authentication
  • Release and migration notes
  • Glossary
ftrack Python API
  • Docs »
  • Usage examples »
  • Using link attributes
  • Edit on Bitbucket

Using link attributesΒΆ

The link attribute can be used to retreive the ids and names of the parents of an object. It is particularly useful in cases where the path of an object must be presented in a UI, but can also be used to speedup certain query patterns.

You can use the link attribute on any entity inheriting from a Context or AssetVersion. Here we use it on the Task entity:

task = session.query(
    'select link from Task where name is "myTask"'
).first()
print(task['link'])

It can also be used create a list of parent entities, including the task itself:

entities = []
for item in task['link']:
    entities.append(session.get(item['type'], item['id']))

The link attribute is an ordered list of dictionaries containting data of the parents and the item itself. Each dictionary contains the following entries:

id
The id of the object and can be used to do a Session.get().
name
The name of the object.
type
The schema id of the object.

A more advanced use-case is to get the parent names and ids of all timelogs for a user:

for timelog in session.query(
    'select context.link, start, duration from Timelog '
    'where user.username is "john.doe"'
):
    print(timelog['context']['link'], timelog['start'], timelog['duration'])

The attribute is also available from the AssetVersion asset relation:

for asset_version in session.query(
    'select link from AssetVersion '
    'where user.username is "john.doe"'
):
    print(asset_version['link'])
Next Previous

© Copyright 2014, ftrack Revision 825de44d.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
master
latest
stable
2.3.0
2.2.0
2.2.0rc1
2.1.2
2.1.1
2.1.0
2.0.0
backlog-threading-story
backlog-fix-readthedocs-build
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.