# 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)

  Bases: `LesanaType`

  A boolean value

  empty()
  load(data)
  name = 'boolean'

class lesana.types.LesanaDate(field, types, value_index=None)

  Bases: `LesanaType`

  A date

  auto(value)

    Return an updated value.

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

  empty()
  load(data)
  name = 'date'

class lesana.types.LesanaDatetime(field, types, value_index=None)

  Bases: `LesanaType`

  A datetime

  auto(value)

    Return an updated value.

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

  empty()
  load(data)
  name = 'datetime'

class lesana.types.LesanaDecimal(field, types, value_index=None)

  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()
  load(data)
  name = 'decimal'

class lesana.types.LesanaFile(field, types, value_index=None)

  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)

  Bases: `LesanaType`

  A floating point number

  empty()
  load(data)
  name = 'float'

class lesana.types.LesanaGeo(field, types, value_index=None)

  Bases: `LesanaString`

  A Geo URI

  load(data)
  name = 'geo'

class lesana.types.LesanaInt(field, types, value_index=None)

  Bases: `LesanaType`

  An integer number

  auto(value)

    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()
  load(data)
  name = 'integer'

class lesana.types.LesanaList(field, types, value_index=None)

  Bases: `LesanaType`

  A list of other values

  empty()
  index(doc, indexer, value)

    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)
  name = 'list'

class lesana.types.LesanaString(field, types, value_index=None)

  Bases: `LesanaType`

  A string of unicode text

  empty()
  load(data)
  name = 'string'

class lesana.types.LesanaText(field, types, value_index=None)

  Bases: `LesanaString`

  A longer block of unicode text

  name = 'text'

class lesana.types.LesanaTimestamp(field, types, value_index=None)

  Bases: `LesanaType`

  A unix timestamp, assumed to be UTC

  empty()
  load(data)
  name = 'timestamp'

class lesana.types.LesanaType(field, types, value_index=None)

  Bases: `object`

  Base class for lesana field types.

  allowed_value(value)

    Check whether a value is allowed in this field.

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

  auto(value)

    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()
  index(doc, indexer, value)

    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)

class lesana.types.LesanaURL(field, types, value_index=None)

  Bases: `LesanaString`

  An URL

  name = 'url'

exception lesana.types.LesanaValueError

  Bases: `ValueError`

  Raised in case of validation errors.

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

  Bases: `LesanaType`

  Free YAML contents (no structure is enforced)

  empty()
  load(data)
  name = 'yaml'