Jump to content

Should projections be encoded/serialized


Nebukadhezer

Recommended Posts

Posted

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....

Cheers

Johannes

 

Posted

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>

 

Posted
Quote

 would you also say nested projections like entity.attribute should be serialized in encode

No,  collection projections are not fully serialised using encode. They are serialised only with entity type and primary keys.

Archived

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

×
×
  • Create New...