sgsession.Entity
¶
-
class
sgsession.entity.
Entity
(type_, id_, session)¶ A Shotgun entity.
This behaves much like the
dict
the Shotgun API normally returns does, but understands the links bettween entities in its associated session.
Entity Management¶
-
Entity.
as_dict
()¶ Return the entity and all linked entities as pure
dict
.The first reference to an entity will have all availible fields, and any subsequent ones will be the minimal representation. This is the ideal format for serialization and remerging into a session.
-
Entity.
pprint
(backrefs=None, depth=0)¶ Print this entity, all links and optional backrefs.
-
Entity.
exists
(*args, **kwargs)¶ Determine if this entity still exists (non-retired) on the server.
Parameters: Returns bool: True/False if it is known to exist or not, and None if we do not know.
See
Session.filter_exists()
for the bulk version.
Retrieving Data¶
-
Entity.
get
(*args, **kwargs)¶ Get field value(s) if they exist, otherwise a default.
Parameters: - fields – A
str
field name or collection ofstr
field names. - default – Default value to return when field does not exist.
If passed a single field name as a
str
, return the coresponding value. If passed field names as a list or tuple, return a tuple of coresponding values.- fields – A
-
Entity.
fetch
(*args, **kwargs)¶ Get field value(s), automatically fetching them from the server.
Parameters: - fields – A
str
field name or collection ofstr
field names. - default – Default value to return when field does not exist.
- force (bool) – Force an update from the server, otherwise only query they server if fields have been requested that we do not already have.
If passed a single field name as a
str
, return the coresponding value. If passed field names as a list or tuple, return a tuple of coresponding values.See
Session.fetch()
for the bulk version.- fields – A
-
Entity.
fetch_core
(*args, **kwargs)¶ Assert that all “important” fields exist on this Entity.
See
Session.fetch_core()
for the bulk version.
-
Entity.
fetch_backrefs
(*args, **kwargs)¶ Fetch all backrefs to this Entity from the given type and field.
See
Session.fetch_backrefs()
for the bulk version.
-
Entity.
fetch_heirarchy
(*args, **kwargs)¶ Fetch the full upward heirarchy (toward the Project) from the server.
See
Session.fetch_heirarchy()
for the bulk version.
Heirarchy¶
-
Entity.
parent
(*args, **kwargs)¶ Get the parent of this Entity, automatically fetching from the server.
-
Entity.
project
(*args, **kwargs)¶ Get the project of this Entity, automatically fetching from the server.
Depending on what part of the heirarchy is already loaded, many more entities will have their Project fetched by this single call.