Storage
Filesystem storage with mount system.
LocalStorage - Filesystem-only storage with genro-storage compatible API.
This module provides a minimal storage implementation that uses the same API as genro-storage, but only supports local filesystem. When genro-storage becomes available, simply change the import:
# Before (local only) from genro_asgi.storage import LocalStorage
# After (full genro-storage) from genro_storage import StorageManager as LocalStorage
- class genro_asgi.storage.LocalStorage(base_dir=None)[source]
Bases:
objectStorage manager filesystem-only. API compatible with genro_storage.StorageManager.
Mount resolution order (see _resolve_mount): 1. Method mount_{prefix}() → dynamic, overridable via subclass 2. Dict _mounts → configured from config.yaml 3. ValueError if not found
- add_mount(config)[source]
Add a single mount point.
- Parameters:
config (
dict[str,Any]) – {‘name’: str, ‘type’: ‘local’, ‘path’: str}- Raises:
ValueError – if type != ‘local’
ValueError – if name already exists
- Return type:
- configure(source)[source]
Configure mount points from list of dicts.
- Format:
[{‘name’: ‘site’, ‘type’: ‘local’, ‘path’: ‘/path/to/dir’}]
Note
Only type=’local’ is supported. Other types raise ValueError.
- node(mount_or_path=None, *path_parts)[source]
Create a storage node.
- Parameters:
- Return type:
- Returns:
LocalStorageNode for the specified path
Examples
storage.node(‘site:resources/logo.png’) storage.node(‘site’, ‘resources’, ‘logo.png’) storage.node(‘site:resources’, ‘images’, ‘logo.png’)
- Raises:
ValueError – if mount doesn’t exist
- class genro_asgi.storage.LocalStorageNode(storage, mount, path)[source]
Bases:
objectStorage node for local filesystem. API compatible with genro_storage.StorageNode.
- property parent: LocalStorageNode
Return parent directory node.
- class genro_asgi.storage.StorageNode(*args, **kwargs)[source]
Bases:
ProtocolAbstract interface for storage nodes.
Any storage backend (local, S3, HTTP) must implement this protocol. LocalStorageNode is the filesystem implementation.