Objects
rn_forge.commons.integration.objects
Object-storage protocols: put/get/delete/exists plus a pre-signed URL.
url_for returns a time-limited pre-signed URL (a SAS URL on Azure, a
presigned URL on S3) so a client downloads directly instead of streaming
bytes through the application. expires_in is required, not defaulted — a
pre-signed URL with a forgotten expiry is a leak with a long tail.
AsyncObjectStore
Bases: Protocol
The async counterpart of :class:ObjectStore.
delete(key)
async
Delete the object at key. A no-op when key does not exist.
exists(key)
async
Return whether an object exists at key.
get(key)
async
put(key, data, *, content_type=None)
async
Store data at key, overwriting any existing object.
url_for(key, *, expires_in)
async
Return a time-limited pre-signed URL for key, valid for expires_in.
InMemoryObjectStore()
Dict-backed store for tests. url_for raises NotImplementedError.
delete(key)
Delete the object at key. A no-op when key does not exist.
exists(key)
Return whether an object exists at key.
get(key)
put(key, data, *, content_type=None)
Store data at key, overwriting any existing object. content_type is ignored.
url_for(key, *, expires_in)
Not supported by the in-memory store — always raises.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
Always — a fabricated URL would prove nothing. |
ObjectNotFound(message, *message_args, error_code=-1, **error_data)
Bases: AppException
No object exists at the given key.
check(value, message, *message_args, **kwargs)
classmethod
Raise this exception if value is falsy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to test. |
required |
message
|
str
|
Exception message (supports positional format args). |
required |
*message_args
|
Any
|
Forwarded to |
()
|
**kwargs
|
Any
|
Forwarded as |
{}
|
Example::
AppException.check(path.exists(), "Missing file: {}", path, error_code=404)
ObjectStore
Bases: Protocol
A synchronous object-storage protocol.
delete(key)
Delete the object at key. A no-op when key does not exist.
exists(key)
Return whether an object exists at key.
get(key)
put(key, data, *, content_type=None)
Store data at key, overwriting any existing object.
url_for(key, *, expires_in)
Return a time-limited pre-signed URL for key, valid for expires_in.