flywheel.fields.types module

Field type definitions

class flywheel.fields.types.BinaryType[source]

Bases: flywheel.fields.types.TypeDefinition

Binary strings, stored as a str/bytes

aliases = ['B', <class 'dynamo3.types.Binary'>][source]
coerce(value, force)[source]
data_type[source]

alias of str

ddb_data_type = 'B'[source]
ddb_dump(value)[source]
ddb_load(value)[source]
class flywheel.fields.types.BoolType[source]

Bases: flywheel.fields.types.TypeDefinition

Boolean type

coerce(value, force)[source]
data_type[source]

alias of bool

ddb_data_type = 'BOOL'[source]
class flywheel.fields.types.DateTimeType[source]

Bases: flywheel.fields.types.TypeDefinition

Datetimes, stored as a unix timestamp

data_type[source]

alias of datetime

ddb_data_type = 'N'[source]
ddb_dump(value)[source]
ddb_load(value)[source]
class flywheel.fields.types.DateType[source]

Bases: flywheel.fields.types.TypeDefinition

Dates, stored as timestamps

data_type[source]

alias of date

ddb_data_type = 'N'[source]
ddb_dump(value)[source]
ddb_load(value)[source]
class flywheel.fields.types.DecimalType[source]

Bases: flywheel.fields.types.TypeDefinition

Numerical values that use Decimal in the application layer.

This should be used if you want to work with floats but need the additional precision of the Decimal type.

coerce(value, force)[source]
data_type[source]

alias of Decimal

ddb_data_type = 'N'[source]
class flywheel.fields.types.DictType[source]

Bases: flywheel.fields.types.TypeDefinition

Dict type, stored as a map

coerce(value, force)[source]
data_type[source]

alias of dict

ddb_data_type = 'M'[source]
mutable = True[source]
class flywheel.fields.types.FloatType[source]

Bases: flywheel.fields.types.TypeDefinition

Float values

coerce(value, force)[source]
data_type[source]

alias of float

ddb_data_type = 'N'[source]
ddb_load(value)[source]
class flywheel.fields.types.IntType[source]

Bases: flywheel.fields.types.TypeDefinition

Integer values (includes longs)

aliases = [<type 'int'>, <type 'long'>][source]
coerce(value, force)[source]
data_type[source]

alias of int

ddb_data_type = 'N'[source]
ddb_load(value)[source]
class flywheel.fields.types.ListType[source]

Bases: flywheel.fields.types.TypeDefinition

List type

coerce(value, force)[source]
data_type[source]

alias of list

ddb_data_type = 'L'[source]
mutable = True[source]
class flywheel.fields.types.NumberType[source]

Bases: flywheel.fields.types.TypeDefinition

Any kind of numerical value

coerce(value, force)[source]
data_type = 'N'[source]
ddb_data_type = 'N'[source]
ddb_load(value)[source]
class flywheel.fields.types.SetType(item_type=None, type_class=None)[source]

Bases: flywheel.fields.types.TypeDefinition

Set types

classmethod bind(item_type)[source]

Create a set factory that will contain a specific data type

coerce(value, force)[source]
data_type[source]

alias of set

ddb_dump(value)[source]
ddb_dump_inner(value)[source]

We need to expose this for ‘contains’ and ‘ncontains’

ddb_load(value)[source]
mutable = True[source]
class flywheel.fields.types.StringType[source]

Bases: flywheel.fields.types.TypeDefinition

String values, stored as unicode

aliases = ['S'][source]
coerce(value, force)[source]
data_type[source]

alias of unicode

ddb_data_type = 'S'[source]
class flywheel.fields.types.TypeDefinition[source]

Bases: flywheel.compat.UnicodeMixin

Base class for all Field types

Attributes

data_type (object) The value you wish to pass in to Field as the data_type.
aliases (list) Other values that will reference this type if passed to Field
ddb_data_type ({STRING, BINARY, NUMBER, STRING_SET, BINARY_SET, NUMBER_SET, BOOL, LIST, MAP}) The DynamoDB data type that backs this type
mutable (bool) If True, flywheel will track updates to this field automatically when making calls to sync()
allowed_filters (set) The set of filters that can be used on this field type
aliases = [][source]
coerce(value, force)[source]

Check the type of a value and possible convert it

Parameters:

value : object

The value to check

force : bool

If True, always attempt to convert a bad type to the correct type

Returns:

value : object

A variable of the correct type

Raises:

exc : TypeError or ValueError

If the value is the incorrect type and could not be converted

data_type = None[source]
ddb_data_type = None[source]
ddb_dump(value)[source]

Dump a value to a form that can be stored in DynamoDB

ddb_dump_inner(value)[source]

If this is a set type, dump a value to the type contained in the set

ddb_load(value)[source]

Turn a value into this type from a DynamoDB value

mutable = False[source]
class flywheel.fields.types.UTCTimezone[source]

Bases: datetime.tzinfo

UTC

dst(dt)[source]
tzname(dt)[source]
utcoffset(dt)[source]
flywheel.fields.types.register_type(type_class, allow_in_set=True)[source]

Register a type class for use with Fields

flywheel.fields.types.set_(data_type)[source]

Create an alias for a SetType that contains this data type