mod:dossier.store provides a convenient interface to a mod:kvlayer
table for storing dossier.fc.FeatureCollection. The
interface consists of methods to query, search, add and remove feature
collections from the store. It also provides functions for defining and
searching indexes.

Using a storage backend in your code requires a working kvlayer
configuration, which is usually written in a YAML file like so:

Here is another example that demonstrates use of indexing to enable a
poor man’s case insensitive search:

fc=dossier.fc.FeatureCollection()fc[u'NAME'][u'foo']+=1fc[u'NAME'][u'bar']=42kvl=kvlayer.client()store=dossier.store.Store(kvl)# Index transforms must be defined on every instance of `Store`.# (The index data is persisted; the transforms themselves are# ephemeral.)store.define_index(u'name_casei',create=feature_index(u'NAME'),transform=lambdas:s.lower().encode('utf-8'))store.put('{yourid}',fc)# `put` automatically updates indexes.assertlist(store.index_scan(u'name_casei','FoO'))[0]=='{yourid}'

Every feature collection is keyed by its content_id, which is a
byte string. The value of a content_id is specific to the type
of content represented by the feature collection. In other words,
its representation is unspecified.

Returns a generator of content objects corresponding to the
content identifier ranges given. key_ranges can be a possibly
empty list of 2-tuples, where the first element of the tuple
is the beginning of a range and the second element is the end
of a range. To specify the beginning or end of the table, use
an empty tuple ().

If the list is empty, then this yields all content objects in
the storage.

Parameters:

key_ranges – as described in
kvlayer._abstract_storage.AbstractStorage()

Returns a generator of content_id corresponding to the
content identifier ranges given. key_ranges can be a possibly
empty list of 2-tuples, where the first element of the tuple
is the beginning of a range and the second element is the end
of a range. To specify the beginning or end of the table, use
an empty tuple ().

If the list is empty, then this yields all content ids in
the storage.

Parameters:

key_ranges – as described in
kvlayer._abstract_storage.AbstractStorage()

Adds an index transform to the current FC store. Once an index
with name idx_name is added, it will be available in all
index_* methods. Additionally, the index will be automatically
updated on calls to put().

If an index with name idx_name already exists, then it is
overwritten.

Note that indexes do not persist. They must be re-defined for
each instance of Store.

For example, to add an index on the boNAME feature, you can
use the feature_index helper function: