betty.associations.to_many module

To-many entity associations.

final class betty.associations.to_many.ToMany

Bases: Association[OwnerT, AssociateT, ToManyCollection, ToManyAssociates, DataDefinition], Generic

A *-to-many entity association.

__init__(associate: str | type[AssociateT], associate_attr: str | None = None, /, *, description: ResolvableLocalizable | None = None, label: ResolvableLocalizable)
associate(owner: OwnerT, associate: AssociateT, /) None

Associate two entities.

delete(owner: OwnerT, /) None

Delete the property value from the owner.

Raises:

NotDeletable

disassociate(owner: OwnerT, associate: AssociateT, /) None

Disassociate two entities.

async dump_linked_data_for(project: Project, owner: OwnerT, /) PortableData

Dump the given target to JSON-LD.

get(owner: OwnerT, /) ToManyCollection[OwnerT, AssociateT]

Get the property value from the owner.

get_associates(owner: OwnerT, /) Iterable[AssociateT]

Get the associates for the given owner.

init_owner(owner: OwnerT, /) None

Initialize the property on an owner.

is_resolver(value: Associate[OwnerT, AssociateT], /) TypeGuard[AssociateResolver[OwnerT, AssociateT]]

Test that the value is an entity (associate) resolver.

async linked_data_schema_for(project: Project, /) Schema

Define the JSON Schema for betty.linked_data.LinkedDataDumper.dump_linked_data_for().

resolve(project: Project, owner: OwnerT, /) None

Resolve any associates the owner may have for this association.

set(owner: OwnerT, value: ToManyAssociates[OwnerT, AssociateT], /) None

Set the property value on the owner.

Raises:

NotSettable