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
      • Relations
      • Creating links
      • Limitations
        • Projections
    • 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 custom attributes links
  • Edit on Bitbucket

Using custom attributes links¶

Custom attributes can be queried from entities using the custom_attribute_links and custom_attribute_links_from relations. The “_from” relation represents the reverse direction of a custom attribute link. Say you have a link between Task and AssetVersion, then custom_attribute_links represent “Task -> AssetVersion” while custom_attribute_links_from represent “AssetVersion -> Task”. The relations can only be used to query and filter the result, to read the actual values you need to query CustomAttributeLink objects directly.

Below are a few examples of how to query and filter using the custom_attribute_links relation:

for task in session.query(
    'select name from Task where custom_attribute_links any '
    '(configuration.key is "supervisor" and user.username is "foobar")'
):
    print(task['name'])

for user in session.query(
    'select username from User where custom_attribute_links_from any '
    '(configuration.key is "supervisor" and context.bid > 1)'
):
    print(user['username'])

Below is an example of how to read the values of custom attribute links:

for value in session.query(
    'select user from CustomAttributeLink where '
    'configuration.key = "supervisor" and from_id = "MY_TASK_ID"'
):
    print(value['user'])

Relations¶

The CustomAttributeLink object have relations to the entities that can be used when filtering a query. In the above examples we are using the “user” and “context” relations. You can see these relations in the API reference documentation available on your ftrack workspace if you look for “CustomAttributeLink” objects that are prefixed such as “UserCustomAttributeLink” and “ContextCustomAttributeLink”.

Creating links¶

To create a link between two entities you need to create a CustomAttributeLink entity like this:

session.create('CustomAttributeLink', {
    'from_id': my_task_id,
    'to_id': my_user_id,
    'configuration_id': my_configuration_id
})

If you need to create the CustomAttributeLinkConfiguration entity, please read this.

Limitations¶

Projections¶

It is currently not possible to use the custom_attribute_links relation as a projection.

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.