Strings, Numbers and Booleans

Strings

class String(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Scalar

A regular old text string.

adapt(value)

Return a Python representation.

Returns:a text value or None

If strip is true, leading and trailing whitespace will be removed.

is_empty

True if the String is missing or has no value.

serialize(value)

Return a text representation.

Returns:a Unicode value or u'' if value is None

If strip is true, leading and trailing whitespace will be removed.

Numbers

class Integer(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Number

Element type for Python’s int.

type_

alias of __builtin__.int

class Long(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Number

Element type for Python’s long.

type_

alias of __builtin__.long

class Float(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Number

Element type for Python’s float.

type_

alias of __builtin__.float

class Decimal(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Number

Element type for Python’s Decimal.

type_

alias of decimal.Decimal

Booleans

class Boolean(value=Unspecified, **kw)

Bases: flatland.schema.scalars.Scalar

Element type for Python’s bool.

adapt(value)

Coerce value to bool.

Returns:a bool or None

If value is text, returns True if the value is in true_synonyms, False if in false_synonyms and None otherwise.

For non-text values, equivalent to bool(value).

serialize(value)

Convert bool(value) to a canonical text representation.

Returns:either self.true or self.false.