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:
LesanaTypeA boolean value
- name = 'boolean'¶
- class lesana.types.LesanaDate(field, types, value_index=None)[source]¶
Bases:
LesanaTypeA date
- auto(value)[source]¶
Return an updated value.
If the field settings
autoisupdatereturn the current date, otherwise the old value.
- name = 'date'¶
- class lesana.types.LesanaDatetime(field, types, value_index=None)[source]¶
Bases:
LesanaTypeA datetime
- auto(value)[source]¶
Return an updated value.
If the field settings
autoisupdatereturn the current datetime, otherwise the old value.
- name = 'datetime'¶
- class lesana.types.LesanaDecimal(field, types, value_index=None)[source]¶
Bases:
LesanaTypeA 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
precisioncan 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:
LesanaStringA 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:
LesanaTypeA floating point number
- name = 'float'¶
- class lesana.types.LesanaGeo(field, types, value_index=None)[source]¶
Bases:
LesanaStringA Geo URI
- name = 'geo'¶
- class lesana.types.LesanaInt(field, types, value_index=None)[source]¶
Bases:
LesanaTypeAn integer number
- auto(value)[source]¶
Return an updated value.
If the field settings
autoisincrementreturn 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:
LesanaTypeA 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:
LesanaTypeA string of unicode text
- name = 'string'¶
- class lesana.types.LesanaText(field, types, value_index=None)[source]¶
Bases:
LesanaStringA longer block of unicode text
- name = 'text'¶
- class lesana.types.LesanaTimestamp(field, types, value_index=None)[source]¶
Bases:
LesanaTypeA unix timestamp, assumed to be UTC
- name = 'timestamp'¶
- class lesana.types.LesanaType(field, types, value_index=None)[source]¶
Bases:
objectBase 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:
LesanaStringAn URL
- name = 'url'¶