minimalkv.decorator module¶
- class minimalkv.decorator.KeyTransformingDecorator(store: KeyValueStore)¶
Bases:
StoreDecorator
- get(key, *args, **kwargs)¶
- class minimalkv.decorator.PrefixDecorator(prefix: str, store: KeyValueStore)¶
Bases:
KeyTransformingDecorator
Prefixes any key with a string before passing it on the decorated store.
Automatically strips the prefix upon key retrieval.
Parameters¶
- storeKeyValueStore
The store to pass keys on to.
- prefixstr
Prefix to add.
- class minimalkv.decorator.ReadOnlyDecorator(store: KeyValueStore)¶
Bases:
StoreDecorator
A read-only view of an underlying minimalkv store.
Provides only access to the following methods/attributes of the underlying store:
get
,iter_keys
,keys
,open
,get_file
and__contains__
. Accessing any other method will raiseAttributeError
.Note that the original store for read / write can still be accessed, so using this class as a wrapper only provides protection against bugs and other kinds of unintentional writes; it is not meant to be a real security measure.
- class minimalkv.decorator.StoreDecorator(store: KeyValueStore)¶
Bases:
object
Base class for store decorators.
The default implementation will use
getattr()
to pass through all attribute/method requests to an underlying object stored as_dstore
. It will also pass through the__getattr__
and__contains__
python special methods.Attributes¶
- _dstore: KeyValueStore
Store.
Parameters¶
- store: KeyValueStore
Store.
- close()¶
Relay a close call to the next decorator or underlying store.
- class minimalkv.decorator.URLEncodeKeysDecorator(store: KeyValueStore)¶
Bases:
KeyTransformingDecorator
URL-encodes keys before passing them on to the underlying store.