ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

module documentation

Attribute handling behavior shared by every model.

Class AttributesMixin Attribute handling behavior shared by every model.
Function _cast_bool Cast a raw value to bool handling common textual forms.
Function _cast_date Cast a raw value to date.
Function _cast_datetime Cast a raw value to datetime.
Function _cast_json Cast a raw value to a JSON-decoded Python structure.
Function _cast_uuid Cast a raw value to uuid.UUID.
Function get_cast_handler Return the cast handler registered under the given name.
Function serialize_for_storage Convert attribute values into driver-friendly storage values.
Constant _CAST_HANDLERS Registry of supported cast names.
Constant _TRUTHY_STRINGS Strings interpreted as truthy when casting to bool.
def _cast_bool(value: Any) -> bool: (source)

Cast a raw value to bool handling common textual forms.

Parameters
value:typing.AnyRaw attribute value.
Returns
boolBoolean representation of the value.
def _cast_date(value: Any) -> date: (source)

Cast a raw value to date.

Parameters
value:typing.AnyDate, datetime, or ISO-8601 string.
Returns
datetime.dateDate representation of the value.
def _cast_datetime(value: Any) -> datetime: (source)

Cast a raw value to datetime.

Parameters
value:typing.AnyDatetime instance, ISO-8601 string, or POSIX timestamp.
Returns
datetime.datetimeDatetime representation of the value.
def _cast_json(value: Any) -> Any: (source)

Cast a raw value to a JSON-decoded Python structure.

Parameters
value:typing.AnyJSON string, or an already decoded structure.
Returns
typing.AnyDecoded Python structure.
def _cast_uuid(value: Any) -> uuid.UUID: (source)

Cast a raw value to uuid.UUID.

Parameters
value:typing.AnyUUID instance or its string form.
Returns
uuid.UUIDUUID representation of the value.
def get_cast_handler(cast: str) -> Callable[[Any], Any]: (source)

Return the cast handler registered under the given name.

Parameters
cast:strCast name declared in a model casts mapping.
Returns
collections.abc.CallableFunction converting raw values into the cast type.
Raises
orionis.orm.exceptions.OrmExceptionIf the cast name is not supported.
def serialize_for_storage(meta: metaclass_module.ModelMetadata, values: dict[str, Any]) -> dict[str, Any]: (source)

Convert attribute values into driver-friendly storage values.

Structures stored outside JSON or PickleType columns are serialized to strings, and UUID objects targeting neither UUID nor PickleType columns are stringified; every other value passes through unchanged.

Parameters
meta:orionis.orm.metaclass.ModelMetadataMetadata of the model owning the attributes.
values:dictAttribute values to serialize.
Returns
dictValues ready to be bound into an SQL statement.
_CAST_HANDLERS: dict[str, Callable[[Any], Any]] = (source)

Registry of supported cast names.

Value
{'int': int,
 'float': float,
 'bool': _cast_bool,
 'datetime': _cast_datetime,
 'date': _cast_date,
 'json': _cast_json,
 'uuid': _cast_uuid}
_TRUTHY_STRINGS: frozenset[str] = (source)

Strings interpreted as truthy when casting to bool.

Value
frozenset(set(['1', 'true', 'yes', 'on']))