# lesana.collection module

class lesana.collection.Collection(directory=None, itemdir='items')

  Bases: `object`

  PARSER_FLAGS = 23
  entries_from_short_eid(seid)
  entry_from_eid(eid)
  entry_from_rendered_template(template, data)
  get_all_documents()

    Yield all documents in the collection.

    Note that the results can’t be sorted, even if the collection has a default_sort; if you need sorted values you need to use a regular search with a query of ‘*’

  get_all_search_results()
  get_field_values(field, querystring='*')
  get_search_results(offset=0, pagesize=12)
  get_template(template_fname, searchpath='.')
  git_add_files(files=[])
  property indexed_fields
  classmethod init(directory=None, git_enabled=True, edit_file=None, settings={})

    Initialize a lesana repository

    directory defaults to . if git_enabled is True, git support is enabled and if possible a git repository is initalized. edit_file is a syncronous function that runs on a filename (possibly opening the file in an editor) and should manage its own errors.

  remove_entries(eids)
  remove_file(fname)
  render_query_template(query)

    Render a query template, filling it with search_aliases.

  save_entries(entries=[])
  start_search(querystring, sort_by=None)

    Prepare a search for querystring.

  update_cache(fnames=None, reset=False)

    Update the xapian db with the data in files.

    `fnames` is a list of basenames of files in `self.itemdir`.

    If no files have been passed, add everything.

    if `reset` the existing xapian db is deleted before indexing

    Return the number of files that have been added to the cache.

  update_field(query, field, value)

class lesana.collection.Entry(collection, data={}, fname=None)

  Bases: `object`

  auto()

    Update all fields of this entry, as required by the field settings.

    This is called by the reference client before an edit, so that the user can make further changes.

    Note that the stored file is not changed: if you need it you need to save the entry yourself.

  empty_data()
  get_data()
  property idterm
  render(template, searchpath='.')
  property short_id
  validate()
  property yaml_data

exception lesana.collection.TemplatingError

  Bases: `Exception`

  Raised when there are errors rendering a jinja template