flywheel.model_meta module

Model metadata and metaclass objects

class flywheel.model_meta.ModelMetaclass(name, bases, dct)[source]

Bases: type

Metaclass for Model objects

Merges model metadata, sets the meta_ attribute, and performs validation checks.

class flywheel.model_meta.ModelMetadata(model)[source]

Bases: object

Container for model metadata

Parameters:model : Model

Attributes

abstract Getter for abstract
namespace list() -> new empty list
abstract[source]

Getter for abstract

create_dynamo_schema(connection, tablenames=None, test=False, wait=False, throughput=None)[source]

Create all Dynamo tables for this model

Parameters:

connection : DynamoDBConnection

tablenames : list, optional

List of tables that already exist. Will call ‘describe’ if not provided.

test : bool, optional

If True, don’t actually create the table (default False)

wait : bool, optional

If True, block until table has been created (default False)

throughput : dict, optional

The throughput of the table and global indexes. Has the keys ‘read’ and ‘write’. To specify throughput for global indexes, add the name of the index as a key and another ‘read’, ‘write’ dict as the value.

Returns:

table : str

Table name that was created, or None if nothing created

ddb_table(connection)[source]

Construct a Dynamo table from a connection

ddb_tablename[source]

The name of the DynamoDB table

delete_dynamo_schema(connection, tablenames=None, test=False, wait=False)[source]

Drop all Dynamo tables for this model

Parameters:

connection : DynamoDBConnection

tablenames : list, optional

List of tables that already exist. Will call ‘describe’ if not provided.

test : bool, optional

If True, don’t actually delete the table (default False)

wait : bool, optional

If True, block until table has been deleted (default False)

Returns:

table : str

Table name that was deleted, or None if nothing deleted

get_ordering_from_fields(eq_fields, fields)[source]

Get a unique ordering from constraint fields

Parameters:

eq_fields : list

List of field names that are constrained with ‘=’.

fields : list

List of field names that are constrained with inequality operators (‘>’, ‘<’, ‘beginswith’, etc)

Returns:

ordering : Ordering

Raises:

exc : TypeError

If more than one possible Ordering is found

get_ordering_from_index(index)[source]

Get the ordering with matching index name

hk(obj=None, scope=None)[source]

Construct the primary key value

namespace = [][source]
pk_dict(obj=None, scope=None, ddb_dump=False)[source]

Get the dynamo primary key dict for an item

post_create()[source]

Create the orderings

post_validate()[source]

Build the dict of related fields

rk(obj=None, scope=None)[source]

Construct the range key value

validate_model()[source]

Perform validation checks on the model declaration

class flywheel.model_meta.Ordering(meta, hash_key, range_key=None, index_name=None)[source]

Bases: object

A way that the models are ordered

This will be a combination of a hash key and a range key. It may be the primary key, a local secondary index, or a global secondary index.

query_kwargs(**kwargs)[source]

Get the boto query kwargs for querying against this index

exception flywheel.model_meta.ValidationError[source]

Bases: exceptions.Exception

Model inconsistency

flywheel.model_meta.merge_metadata(cls)[source]

Merge all the __metadata__ dicts in a class’s hierarchy

keys that do not begin with ‘_’ will be inherited.

keys that begin with ‘_’ will only apply to the object that defines them.

Read the Docs v: 0.1.3
Versions
latest
0.1.3
0.1.2
0.1.1
0.1.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.