Jump to content

Get all objects from User Groups


Nebukadhezer

Recommended Posts

Hey 

I was wondering if one can get all Tasks/Versions etc by a group name if any assignee is in that group...
 

GROUP_NAME = "Ape"
test = session.query("AssetVersion where task.assignments.resource.memberships.group.name is {}".format(GROUP_NAME)).one()

This results in a 
 

KeyError("Multiple schemas [u'Group', u'User'] found for relationship memberships.")

Can I narrow down that I only want type group ?

Cheers

Johannes

Link to comment
Share on other sites

  • 1 month later...

Hi, I've been trying to use casting with the `populate` command, but I can't find anything that works. Is it not supported or am I doing something wrong?

>>> shot = session.get('Shot', shot_id)
>>> session.populate(shot, 'children.status')
ServerError: Server reported error: KeyError("Multiple schemas [u'Project', u'TypedContext'] found for relationship u'status'.")

>>> session.populate(shot, 'children[Project].status')
>>> session.populate(shot, 'children[TypedContext].status')
ServerError: Server reported error: KeyError(u'children[Project]')
  
>>> session.populate(shot, 'children.status[Project]')
>>> session.populate(shot, 'children.status[TypedContext]')
ServerError: Server reported error: KeyError(u"No attribute u'status[Project]' exists for schema u'Context'."

 

Link to comment
Share on other sites

Hey Peter,

What you're running in to is the fact that populate() constructs a query using that attribute string, and we don't support typecasting in a projection. see https://bitbucket.org/ftrack/ftrack-python-api/src/23f582cd146e71f871ba8a17da30c0ad831de836/source/ftrack_api/session.py#lines-1070
We do support passing a list, tuple or QueryResult, so my workaround would be something like the populate line in this snippet. The rest is just included to set up my example / test.

shot = session.query('select children from Shot where children is_not None').first()
session.populate(shot['children'][:], 'status')
with session.auto_populating(False):
    print(shot['children'][0]['name'])
    print(shot['children'][0]['status'])

I suppose the root cause of all this is that children maps to Contexts, which can include Projects, which themselves do not have statuses.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...