lesana.types module

Type checkers for lesana fields.

Warning: this part of the code is still in flux and it may change significantly in a future release.

class lesana.types.LesanaBoolean(field, types, value_index=None)[source]

Bases: LesanaType

A boolean value

empty()[source]
load(data)[source]
name = 'boolean'
class lesana.types.LesanaDate(field, types, value_index=None)[source]

Bases: LesanaType

A date

auto(value)[source]

Return an updated value.

If the field settings auto is update return the current date, otherwise the old value.

empty()[source]
load(data)[source]
name = 'date'
class lesana.types.LesanaDatetime(field, types, value_index=None)[source]

Bases: LesanaType

A datetime

auto(value)[source]

Return an updated value.

If the field settings auto is update return the current datetime, otherwise the old value.

empty()[source]
load(data)[source]
name = 'datetime'
class lesana.types.LesanaDecimal(field, types, value_index=None)[source]

Bases: LesanaType

A fixed point number

Because of a limitation of the yaml format, these should be stored quoted as a string, to avoid being loaded back as floats.

Alternatively, the property precision can be used to force all values to be rounded to that number of decimals.

empty()[source]
load(data)[source]
name = 'decimal'
class lesana.types.LesanaFile(field, types, value_index=None)[source]

Bases: LesanaString

A path to a local file.

Relative paths are assumed to be relative to the base lesana directory (i.e. where .lesana lives)

name = 'file'
class lesana.types.LesanaFloat(field, types, value_index=None)[source]

Bases: LesanaType

A floating point number

empty()[source]
load(data)[source]
name = 'float'
class lesana.types.LesanaGeo(field, types, value_index=None)[source]

Bases: LesanaString

A Geo URI

load(data)[source]
name = 'geo'
class lesana.types.LesanaInt(field, types, value_index=None)[source]

Bases: LesanaType

An integer number

auto(value)[source]

Return an updated value.

If the field settings auto is increment return the value incremented by the value of the field setting increment (default 1).

empty()[source]
load(data)[source]
name = 'integer'
class lesana.types.LesanaList(field, types, value_index=None)[source]

Bases: LesanaType

A list of other values

empty()[source]
index(doc, indexer, value)[source]

Index a value for this field type.

Override this for types that need any kind of special treatment to be indexed.

See LesanaList for an idea on how to do so.

load(data)[source]
name = 'list'
class lesana.types.LesanaString(field, types, value_index=None)[source]

Bases: LesanaType

A string of unicode text

empty()[source]
load(data)[source]
name = 'string'
class lesana.types.LesanaText(field, types, value_index=None)[source]

Bases: LesanaString

A longer block of unicode text

name = 'text'
class lesana.types.LesanaTimestamp(field, types, value_index=None)[source]

Bases: LesanaType

A unix timestamp, assumed to be UTC

empty()[source]
load(data)[source]
name = 'timestamp'
class lesana.types.LesanaType(field, types, value_index=None)[source]

Bases: object

Base class for lesana field types.

allowed_value(value)[source]

Check whether a value is allowed in this field.

Return the value itself or raise LesanaValueError if the value isn’t valid.

auto(value)[source]

Return an updated value, as appropriate for the field.

Default is to return the value itself, but types can use their configuration to e.g. increment a numerical value or return the current date(time).

empty()[source]
index(doc, indexer, value)[source]

Index a value for this field type.

Override this for types that need any kind of special treatment to be indexed.

See LesanaList for an idea on how to do so.

load(data)[source]
class lesana.types.LesanaURL(field, types, value_index=None)[source]

Bases: LesanaString

An URL

name = 'url'
exception lesana.types.LesanaValueError[source]

Bases: ValueError

Raised in case of validation errors.

class lesana.types.LesanaYAML(field, types, value_index=None)[source]

Bases: LesanaType

Free YAML contents (no structure is enforced)

empty()[source]
load(data)[source]
name = 'yaml'