betty.associations.to_one module

To-one entity associations.

final exception betty.associations.to_one.MissingAssociate

Bases: AttributeError, Generic

Raised when a to-one association is missing its required associate.

__init__(association: Association[OwnerT, Any, Any, Any, Any], owner: OwnerT, reason: str, /)
final class betty.associations.to_one.Placeholder

Bases: _MissingAssociate

A placeholder.

classmethod message() str
final class betty.associations.to_one.ToOne

Bases: Association[OwnerT, AssociateT, AssociateT, ToOneAssociate, DataDefinition], Generic

A *-to-one 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(owner: OwnerT, /) None

Delete the property from an owner.

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, /) 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: ToOneAssociate[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().

property optional: Association[OwnerT, AssociateT, AssociateT | None, Associate[OwnerT, AssociateT] | None, DataDefinition[AssociateT | None]]

Return a new association like this one, but that also allows None.

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

Resolve any associates the owner may have for this association.

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

Set the property value on the owner.

Raises:

NotSettable