Development API¶
This page is generally for the developers of sgcache itself, as it does not yet have any Python API’s designed for public consumption.
Cache Data Models¶
-
class
sgcache.entity.
EntityType
(cache, name, schema)[source]¶ Largely a mapping of fields, but also responsible for entity-level caching mechanisms, including columns (on
table.c
):_active
: Is the entity not “retired”?_cache_created_at
: When was this entity first cached?_cache_updated_at
: When was this entity last updated in the cache?_last_log_event_id
: What was the lastLogEventEntry
id to affect this entity?
-
type_name
= None¶ The name of this entity type, e.g.:
Task
.
-
table_name
= None¶ The name of the SQLAlchemy table, usually the lower-cased
type_name
; see Schema Rules.
-
table
= None¶ The SQLAlchemy table itself.
-
schema
= None¶ The
EntitySchema
for this entity type.
Schema¶
-
class
sgcache.schema.
Schema
[source]¶ A mapping of entity type names to
EntitySchema
.-
classmethod
from_yaml
(cls, file)[source]¶ Load the full schema from the given YAML file. This schema is assumed to be:
- a mapping of entity names to entity schemas, which are:
- a mapping of field names to field schemas, which are:
- either a string representing the data type, or a mapping including
a
data_type
, and any other info as required by the field.
-
classmethod
-
class
sgcache.schema.
EntitySchema
(name)[source]¶ A mapping of field names to
FieldSchema
.
Field Paths¶
-
class
sgcache.path.
FieldPath
(input_, root_type=None)[source]¶ A path in an API3 filter or return field; a sequence of
FieldPathSegment
objects.Parameters: - input – A list of
FieldPathSegment
, or a string. - root_type – The entity type this field starts at; required if the input is a string.
>>> path = FieldPath('entity.Shot.sg_sequence.Sequence.code', root_type='Task') >>> str(path) 'entity.Shot.sg_sequence.Sequence.code' >>> str(path[:1]) 'entity' >>> str(path[1:]) 'sg_sequence.Sequence.code'
- input – A list of
API3 Operations¶
-
class
sgcache.api3.create.
Api3CreateOperation
(request, create_with_id=False, source_event=None)[source]¶ Operation to process an API3-style “create” request, which look like:
{ "fields": [ { "field_name": "key", "value": "value" } ], "return_fields": [ "id" ], "type": "Test" }
Parameters: Raises: ValueError – if an ID is given but
create_with_id
is not true.-
entity_exists
= None¶ Did the entity exist? Set to
True
once run if an ID was provided and that entity did exist.
-
before_query
= None¶ List of functions to call with the transaction before the primary query is executed; generally appended to by the
multi_entity
Base
.
-
after_query
= None¶ List of functions to call with the transaction after the primary query is executed; generally appended to by the
multi_entity
Base
.
-
source_event
= None¶ The
Event
that triggered this query.
-