betty.association module¶
Entity associations.
- class betty.association.Association¶
Bases:
LinkedDataDumper[OwnerT,Schema,PortableData],Attr,GenericAn entity association.
- __init__(field: FieldDefinition[OwnerT, GetT, DataDefinitionT] | ResolvableDataDefinition[DataDefinitionT], associate: type[AssociateT] | str, associate_attr: Association[AssociateT, OwnerT, Any, Any] | str | None = None, /, *args: Any, **kwargs: Any)¶
- final assert_not_resolver(owner: OwnerT, value: T, /) Intersection[T, Not[AssociateResolver]]¶
- final assert_not_resolver(owner: OwnerT, value: Any, /) Never
Assert that a value is not an entity (associate) resolver.
- Raises:
- property associate_attr: Association[AssociateT, OwnerT, Any, Any] | None¶
Get the inverse association, if this association is bidirectional.
- property associate_type: type[AssociateT]¶
The type of any associate entities.
This may be an abstract class.
- abstractmethod disassociate(owner: OwnerT, associate: AssociateT, /) None¶
Disassociate two entities.
- abstractmethod get_associates(owner: OwnerT, /) Iterable[AssociateT]¶
Get the associates for the given owner.
- abstractmethod is_resolver(value: Associate[OwnerT, AssociateT], /) TypeGuard[AssociateResolver[OwnerT, AssociateT]]¶
Test that the value is an entity (associate) resolver.
- final class betty.association.BiResolver¶
Bases:
GenericWrap another entity (associate) resolver to bidirectionally associate the owner with the resolved associate.
- __init__(resolver: AssociateResolver[OwnerT, AssociateT], /)¶
- final exception betty.association.UnresolvedAssociate¶
Bases:
ValueErrorRaised when an entity (associate) resolver is encountered unexpectedly.
- __init__(owner: OwnerT, association: Association[OwnerT, AssociateT, Any, Any, DataDefinition], resolver: AssociateResolver, /)¶
- betty.association.resolve_associate(project: Project, owner: OwnerT, association: Association[OwnerT, AssociateT], resolver: AssociateResolver[OwnerT, AssociateT], /) AssociateT¶
Resolve an associate resolver.