The cinder.objects.fields Module

class AbstractFieldType

Bases: object

coerce(obj, attr, value)

This is called to coerce (if possible) a value on assignment.

This method should convert the value given into the designated type, or throw an exception if this is not possible.

:param:obj: The CinderObject on which an attribute is being set :param:attr: The name of the attribute being set :param:value: The value being set :returns: A properly-typed value

describe()

Returns a string describing the type of the field.

from_primitive(obj, attr, value)

This is called to deserialize a value.

This method should deserialize a value from the form given by to_primitive() to the designated type.

:param:obj: The CinderObject on which the value is to be set :param:attr: The name of the attribute which will hold the value :param:value: The serialized form of the value :returns: The natural form of the value

stringify(value)

Returns a short stringified version of a value.

to_primitive(obj, attr, value)

This is called to serialize a value.

This method should serialize a value to the form expected by from_primitive().

:param:obj: The CinderObject on which the value is set :param:attr: The name of the attribute holding the value :param:value: The natural form of the value :returns: The serialized form of the value

class AutoTypedField(**kwargs)

Bases: cinder.objects.fields.Field

AUTO_TYPE = None
class Boolean

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
class BooleanField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Boolean object at 0x2b439c877450>
class CompoundFieldType(element_type, **field_args)

Bases: cinder.objects.fields.FieldType

class DateTime

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
from_primitive(obj, attr, value)
static stringify(value)
static to_primitive(obj, attr, value)
class DateTimeField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.DateTime object at 0x2b439c8774d0>
class Dict(element_type, **field_args)

Bases: cinder.objects.fields.CompoundFieldType

coerce(obj, attr, value)
from_primitive(obj, attr, value)
stringify(value)
to_primitive(obj, attr, value)
class DictOfIntegersField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Dict object at 0x2b439c8777d0>
class DictOfNullableStringsField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Dict object at 0x2b439c8776d0>
class DictOfStringsField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Dict object at 0x2b439c8775d0>
class DictProxyField(dict_field_name, key_type=<type 'int'>)

Bases: object

Descriptor allowing us to assign pinning data as a dict of key_types.

This allows us to have an object field that will be a dict of key_type keys, allowing that will convert back to string-keyed dict.

This will take care of the conversion while the dict field will make sure that we store the raw json-serializable data on the object.

key_type should return a type that unambiguously responds to six.text_type so that calling key_type on it yields the same thing.

exception ElementTypeError(expected, key, value)

Bases: exceptions.TypeError

class Field(field_type, nullable=False, default=<class 'cinder.objects.fields.UnspecifiedDefault'>, read_only=False)

Bases: object

coerce(obj, attr, value)

Coerce a value to a suitable type.

This is called any time you set a value on an object, like:

foo.myint = 1

and is responsible for making sure that the value (1 here) is of the proper type, or can be sanely converted.

This also handles the potentially nullable or defaultable nature of the field and calls the coerce() method on a FieldType to actually do the coercion.

:param:obj: The object being acted upon :param:attr: The name of the attribute/field being set :param:value: The value being set :returns: The properly-typed value

default
describe()

Return a short string describing the type of this field.

from_primitive(obj, attr, value)

Deserialize a value from primitive form.

This is responsible for deserializing a value from primitive into regular form. It calls the from_primitive() method on a FieldType to do the actual deserialization.

:param:obj: The object being acted upon :param:attr: The name of the attribute/field being deserialized :param:value: The value to be deserialized :returns: The deserialized value

nullable
read_only
stringify(value)
to_primitive(obj, attr, value)

Serialize a value to primitive form.

This is responsible for serializing a value to primitive form. It calls to_primitive() on a FieldType to do the actual serialization.

:param:obj: The object being acted upon :param:attr: The name of the attribute/field being serialized :param:value: The value to be serialized :returns: The serialized value

class FieldType

Bases: cinder.objects.fields.AbstractFieldType

static coerce(obj, attr, value)
describe()
static from_primitive(obj, attr, value)
stringify(value)
static to_primitive(obj, attr, value)
class Float

Bases: cinder.objects.fields.FieldType

coerce(obj, attr, value)
class FloatField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Float object at 0x2b439c8773d0>
class IPAddress

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
from_primitive(obj, attr, value)
static to_primitive(obj, attr, value)
class IPNetwork

Bases: cinder.objects.fields.IPAddress

static coerce(obj, attr, value)
class IPV4Address

Bases: cinder.objects.fields.IPAddress

static coerce(obj, attr, value)
class IPV4AndV6Address

Bases: cinder.objects.fields.IPAddress

static coerce(obj, attr, value)
class IPV4Network

Bases: cinder.objects.fields.IPNetwork

static coerce(obj, attr, value)
class IPV6Address

Bases: cinder.objects.fields.IPAddress

static coerce(obj, attr, value)
class IPV6Network

Bases: cinder.objects.fields.IPNetwork

static coerce(obj, attr, value)
class Integer

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
class IntegerField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Integer object at 0x2b439c877350>
exception KeyTypeError(expected, value)

Bases: exceptions.TypeError

class List(element_type, **field_args)

Bases: cinder.objects.fields.CompoundFieldType

coerce(obj, attr, value)
from_primitive(obj, attr, value)
stringify(value)
to_primitive(obj, attr, value)
class ListOfDictOfNullableStringsField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.List object at 0x2b439c877d10>
class ListOfObjectsField(objtype, **kwargs)

Bases: cinder.objects.fields.AutoTypedField

class ListOfSetsOfIntegersField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.List object at 0x2b439c877b90>
class ListOfStringsField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.List object at 0x2b439c8778d0>
class Object(obj_name, **kwargs)

Bases: cinder.objects.fields.FieldType

coerce(obj, attr, value)
describe()
static from_primitive(obj, attr, value)
stringify(value)
static to_primitive(obj, attr, value)
class ObjectField(objtype, **kwargs)

Bases: cinder.objects.fields.AutoTypedField

class Set(element_type, **field_args)

Bases: cinder.objects.fields.CompoundFieldType

coerce(obj, attr, value)
from_primitive(obj, attr, value)
stringify(value)
to_primitive(obj, attr, value)
class SetOfIntegersField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.Set object at 0x2b439c8779d0>
class String

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
static stringify(value)
class StringField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.String object at 0x2b439c877250>
class UUID

Bases: cinder.objects.fields.FieldType

static coerce(obj, attr, value)
class UUIDField(**kwargs)

Bases: cinder.objects.fields.AutoTypedField

AUTO_TYPE = <cinder.objects.fields.UUID object at 0x2b439c8772d0>
class UnspecifiedDefault

Bases: object

Previous topic

The cinder.objects.base Module

Next topic

The cinder.objects.snapshot Module

This Page