Jump to content

Should projections be encoded/serialized


Recommended Posts

I was wondering if a query with projections, that contains values from a projected entity like task.name, context.name, status.name should be included in the encoded version of that data ?
Via session.encode(queryResult) ?
Was thinking to use this to store those on QtUserRoles as the ftrack_api objects wont work there... but I would then love to have the projected values in there....




Link to comment
Share on other sites

I'd like to suggest I different solution - not sure exactly your use-case:

Use the session's built in memory cache and store the identity of the object:

import ftrack_api.inspection
>>> ftrack_api.inspection.identity(task)
('Task', ['00a574b0-1c44-11e2-a9da-f23c91df25eb'])

>>> entity_type, primary_keys = ftrack_api.inspection.identity(task)

And then associate entity_type and primary_keys with the QtUserRoles. Then, later, you can get the cached entity from the same session (no server requests involved since identity is already in the identity map):

>>> session.get(entity_type, primary_keys)
<dynamic ftrack Task object 4550792272>


Link to comment
Share on other sites


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

  • Create New...