s3dol.base¶
Layer B — close-to-metal stores over one bucket or one endpoint.
Design record: misc/docs/architecture.md (the contract tables) on
ADR-0001 (layering; the prefix lives HERE, in the leaf), ADR-0004 (one error
seam), ADR-0005 (write domain / strategies), ADR-0006 (prefix arithmetic and
key validity), ADR-0008 (__len__ absent by design), ADR-0010 (bucket policy),
ADR-0011 (no key-taking public methods — one guarded exception, url_for),
ADR-0012 (connection).
The class triads mirror dol.filesys and azuredol:
BucketCollection -> BucketReader -> BucketStore (keys: object keys)
EndpointCollection -> EndpointReader -> EndpointStore (keys: bucket names)
ObjectHandle (not a Mapping)
Reader-only classes are real classes (a type checker catches
reader[k] = v; a read-scoped credential never even attempts a write) —
dol.mk_read_only is non-functional on a dol store (verified, ADR-0001).
The rule for what may join a class here: nothing that takes a key
(ADR-0011 D1). dol wrappers hand any non-dunder method the outer, unmapped
key, and the standard escape (wrapped_self) is itself silently wrong when
nothing references the wrapper. Keyed capabilities are sibling stores
(s3dol.handles(store)[k] — capabilities.py); per-object richness lives on
ObjectHandle (key bound at construction); everything else is a free
function taking the store first. The single exception is
BucketReader.url_for(), kept for dol.SupportsUrlFor, guarded to be
correct-or-loud (D3b). A reflective conformance test enforces the rule (D5).
Module Attributes
S3's real limit is 1024 UTF-8 bytes (enforced client-side so moto and AWS agree — moto accepts longer keys; ADR-0006 §4). |
|
SigV4's presigned-URL lifetime cap (botocore does not enforce it). |
Functions
|
Clamp to SigV4's 604800 s cap, warning. |
Classes
|
Keys of one bucket (under the prefix). |
|
|
|
|
|
Bucket names at one endpoint. |
|
|
|
|
|
One object, key bound at construction — which is what makes it immune to the delegation trap (a key codec over the store cannot corrupt a key that was resolved before the handle existed; ADR-0011 D1, following |
|
Object metadata — from |
|
AWS profile names -> endpoint stores (the v0 |
Exceptions
Raised by |
- class s3dol.base.BucketCollection(bucket, *, connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)[source]¶
Bases:
_BucketBase,CollectionKeys of one bucket (under the prefix).
Collectiononly — iteration and membership, no reads.
- class s3dol.base.BucketReader(bucket, *, connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)[source]¶
Bases:
BucketCollection,KvReader__getitem__-> bytes (or the read strategy’s value type).
- url_for(k, *, expires_in=3600, client_method='get_object', **params)[source]¶
Presigned URL for
k— the one keyed method (ADR-0011 D3b), kept solely becausedol.SupportsUrlForrequires a method anddol.content_urlreaches it bygetattr. The canonical form iss3dol.urls(store)[k].Guarded to be correct-or-loud, never silently wrong:
unwrapped store:
kis a key in this store’s own key space, so the URL addressesself._id_of_key(k). Correct, and this is also the contractdol.content_urlcalls under — it resolves the key through the outer layers and stops at the layer owningurl_for, “because that layer applies its own” (dol/content.py);this leaf has ever been wrapped: raises. Two call paths then reach this one signature with different key domains and nothing distinguishes them:
dol.content_urlhands over a key already mapped through the wrapper layers, while a directwrapped.url_for(k)(delegation) hands over the raw outer key. Applying_id_of_keyis right for the first and wrong for the second; re-resolving through the chain is right for the second and double-transforms the first. Since a wrong presigned URL addresses a different real object, the only honest answer is refusal, naming the sibling store — which is correct by construction because it goes through__getitem__(ADR-0011 D2/D3b, and see the note below);anonymous connection: returns
None(SupportsUrlForisOptional[str]; raising would turn a public-bucket streaming fallback into a 500 — ADR-0012 D5). The check reads the built client’s signature version, neverspec.anon.
Note
This refusal is a finding, not a limitation we chose. ADR-0011 D3b expected a guarded method to serve both paths; it cannot, on a leaf that owns its prefix. Reported upstream on dol#86/#83 as evidence that a keyed capability method is unfixable in the general case, and that the sibling-store form is the only one correct by construction.
- class s3dol.base.BucketStore(bucket, *, connection=None, prefix='', delimiter='/', reads=None, writes=None, on_missing_bucket='assume', strict_delete=False)[source]¶
Bases:
BucketReader,KvPersister__setitem__/__delitem__. The user-facing read-write store.
- class s3dol.base.EndpointCollection(connection=None, **bucket_kwargs)[source]¶
Bases:
_EndpointBase,CollectionBucket names at one endpoint.
- class s3dol.base.EndpointReader(connection=None, **bucket_kwargs)[source]¶
Bases:
EndpointCollection,KvReader__getitem__->BucketReader.
- class s3dol.base.EndpointStore(connection=None, **bucket_kwargs)[source]¶
Bases:
EndpointReader,KvPersisterbucket creation/deletion.
del endpoint[name]refuses a non-empty bucket; the explicit cascading form is the free functions3dol.delete_bucket(endpoint, name, force=True)(ADR-0010 §3 as amended by ADR-0011 D4 — a public keyed destructive method is the shape the family census found destroying wrong data).
- s3dol.base.MAX_KEY_BYTES = 1024¶
S3’s real limit is 1024 UTF-8 bytes (enforced client-side so moto and AWS agree — moto accepts longer keys; ADR-0006 §4).
- s3dol.base.MAX_PRESIGN_EXPIRES = 604800¶
SigV4’s presigned-URL lifetime cap (botocore does not enforce it).
- class s3dol.base.ObjectHandle(bucket, key, *, connection=None)[source]¶
Bases:
objectOne object, key bound at construction — which is what makes it immune to the delegation trap (a key codec over the store cannot corrupt a key that was resolved before the handle existed; ADR-0011 D1, following
azuredol.BlobHandle). This is where ranged reads, streaming, download-to-disk, metadata and presigned URLs live.- download_to(path)[source]¶
Download to disk (never fully in memory). Accepts a path or
Filepath; returns the path written.- Return type:
- info()[source]¶
One
HeadObject->ObjectInfo.- Return type:
- read(*, offset=None, length=None)[source]¶
The object’s bytes; a ranged read when
offset/lengthgiven.- Return type:
- restore(days=1, *, tier='Standard')[source]¶
Request restoration of an archived (Glacier) object.
- Return type:
- class s3dol.base.ObjectInfo(key, size=None, last_modified=None, etag=None, content_type=None, storage_class=None, restore_status=None, version_id=None)[source]¶
Bases:
objectObject metadata — from
HeadObjector from a LIST row (which already carries size/mtime/etag/storage class that v0 threw away; ADR-0009).
- exception s3dol.base.ObjectNotFoundForDelete[source]¶
-
Raised by
strict_delete=Truedeletes of absent keys.