betty.datas.aggregate.record package¶
Subpackages¶
Submodules¶
Module contents¶
Record data types.
- final class betty.datas.aggregate.record.FieldDefinition¶
Bases:
GenericA record field definition.
- __init__(data: ResolvableDataDefinition[DataDefinition[DataClsT]], *, label: ResolvableLocalizable | None = None, description: ResolvableLocalizable | None = None, omit_load: bool = False, omit_dump: Callable[[DataClsT], bool] | Callable[[OwnerT, DataClsT], bool] | None = None)¶
- data: Final[DataDefinition[DataClsT]]¶
The field’s data definition.
- description: Final[Localizable | None]¶
The human-readable long field description.
- label: Final[Localizable]¶
The human-readable field label.
- final class betty.datas.aggregate.record.MappingPorter¶
Bases:
RecordPorter[DataClsT,Element[str]],GenericLoad and dump a record from and to portable mappings.
- __init__(record: RecordDefinition[DataClsT, ElementT], /)¶
- dump(data: DataClsT, /) PortableMapping¶
Dump data to its portable form.
- dump_key(data: DataClsT, key: ElementT, /) tuple[str, PortableData]¶
Dump the data to portable data and a portable primary key.
- load(portable: PortableData, /) DataClsT¶
Load data from its portable form.
- load_key(portable: PortableData, key: ElementT, portable_key: str, /) DataClsT¶
Create a new data instance from portable data and a portable primary key.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.
- class betty.datas.aggregate.record.PortableRecord¶
Bases:
Portable,Generic[_PortableRecordElementT]A record object capable of dumping and loading itself to and from portable data.
- abstractmethod dump_key(key: _PortableRecordElementT, /) tuple[str, PortableData]¶
Dump the instance to portable data and a portable primary key.
- Raises:
betty.portable.error.NotPortable – Raised if any part of the data is not portable.
- abstractmethod classmethod load_key(portable: PortableData, key: _PortableRecordElementT, portable_key: str, /) Self¶
Create a new instance from portable data and a portable primary key.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.
- final class betty.datas.aggregate.record.PortableRecordPorter¶
Bases:
PortablePorter[PortableRecordT,PortableData],RecordPorter,GenericExpose a portable record data type as a porter.
- dump_key(data: PortableRecordT, key: ElementT, /) tuple[str, PortableData]¶
Dump the data to portable data and a portable primary key.
- load_key(portable: PortableData, key: ElementT, portable_key: str, /) PortableRecordT¶
Create a new data instance from portable data and a portable primary key.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.
- class betty.datas.aggregate.record.RecordDefinition¶
Bases:
AggregateDefinition,GenericA record data definition.
Records have explicitly defined fields.
- __init__(cls: type[DataClsT] | None = None, *, label: ResolvableLocalizable, fields: Mapping[ElementT, FieldDefinition[DataClsT, Any]] | None = None, description: ResolvableLocalizable | None = None, samples: Iterable[Callable[[], Sample[DataClsT]] | Samples] = (), factory: Callable[..., DataClsT] | None = None, porter: RecordPorter[DataClsT] | None = None)¶
- property factory: Callable[..., DataClsT]¶
The factory to create new instances.
The factory’s arguments are kwargs whose names are this record’s field names, and whose values are their fully typed values.
- property fields: Mapping[ElementT, FieldDefinition[DataClsT, Any]]¶
The definitions of the fields contained by this record.
- property porter: RecordPorter[DataClsT]¶
The porter for the data.
- class betty.datas.aggregate.record.RecordPorter¶
Bases:
Porter[DataClsT,PortableData],GenericAn object capable of dumping and loading record data to and from portable data.
- abstractmethod dump_key(data: DataClsT, key: ElementT, /) tuple[str, PortableData]¶
Dump the data to portable data and a portable primary key.
- abstractmethod load_key(portable: PortableData, key: ElementT, portable_key: str, /) DataClsT¶
Create a new data instance from portable data and a portable primary key.
- Raises:
betty.exception.HumanFacingException – Raised if the portable data is invalid.