keepluggable.storage_file.local module

A simple local filesystem storage backend.

class keepluggable.storage_file.local.LocalConfigSchema(*args, **kw)[source]

Bases: colander.Schema

Validated configuration for LocalStorage.

class keepluggable.storage_file.local.LocalFilesystemPower(orchestrator: keepluggable.orchestrator.Orchestrator)[source]

Bases: keepluggable.storage_file.local.LocalStorage

A subclass that contains dangerous methods.

delete_namespace(namespace: str) None[source]

Delete all files in namespace.

empty_bucket() None[source]

Empty the whole bucket, deleting namespaces and files.

gen_paths(namespace: str) Iterable[str][source]

Generate the paths in a namespace. Too costly – avoid.

class keepluggable.storage_file.local.LocalStorage(orchestrator: keepluggable.orchestrator.Orchestrator)[source]

Bases: keepluggable.storage_file.BasePayloadStorage

Local filesystem storage backend.

You should use this for testing only because it is not very robust. It stores files in a very simple directory scheme:

base_storage_directory / namespace / key

Performance will suffer as soon as a couple of thousand files are stored in a namespace.

Keys are MD5 hashes by default. To change this, you would modify the action, not the storage backend.

To enable this backend, use this configuration:

cls_storage_file = keepluggable.storage_file.local.LocalStorage

Configuration settings

Specify in which directory to store payloads like this:

local_storage_path = some.python.resource:relative/directory
delete(namespace: str, metadatas: Sequence[Dict[str, Any]]) None[source]

Delete many files.

get_reader(namespace: str, metadata: Dict[str, Any]) BinaryIO[source]

Return a stream for the file content.

get_superpowers() keepluggable.storage_file.local.LocalFilesystemPower[source]

Get a really dangerous subclass instance.

get_url(namespace: str, metadata: Dict[str, Any], seconds: int = 3600, https: bool = True) str[source]

Return a Pyramid static URL.

If you use another web framework, please override this method.

The seconds and https params are ignored.

put(namespace: str, metadata: Dict[str, Any], bytes_io: BinaryIO) None[source]

Store a file (bytes_io) inside namespace.