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
- 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
isupdate
return the current date, otherwise the old value.
- 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
isupdate
return the current datetime, otherwise the old value.
- 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.- 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
- name = 'float'¶
- class lesana.types.LesanaGeo(field, types, value_index=None)[source]¶
Bases:
LesanaString
A Geo URI
- 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
isincrement
return the value incremented by the value of the field settingincrement
(default 1).
- name = 'integer'¶
- class lesana.types.LesanaList(field, types, value_index=None)[source]¶
Bases:
LesanaType
A list of other values
- 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.
- name = 'list'¶
- class lesana.types.LesanaString(field, types, value_index=None)[source]¶
Bases:
LesanaType
A string of unicode text
- 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
- 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).
- class lesana.types.LesanaURL(field, types, value_index=None)[source]¶
Bases:
LesanaString
An URL
- name = 'url'¶