betty.model.association module¶
Entity associations.
- class betty.model.association.Association[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
]Define an association between two entity types.
- abstract associate(owner: _OwnerT & Entity, associate: _AssociateT & Entity) None [source]¶
Associate two entities.
- abstract disassociate(owner: _OwnerT & Entity, associate: _AssociateT & Entity) None [source]¶
Disassociate two entities.
- final class betty.model.association.AssociationRegistry[source]¶
Bases:
object
Inspect any known entity type associations.
- classmethod get_all_associations(owner: type | object) set[Association[Any, Any]] [source]¶
Get all associations for an owner.
- classmethod get_associates(owner: _EntityT, association: Association[_EntityT, _AssociateT]) Iterable[_AssociateT & Entity] [source]¶
Get the associates for a given owner and association.
- classmethod get_association(owner: type[_OwnerT] | _OwnerT & Entity, owner_attr_name: str) Association[_OwnerT, Any] [source]¶
Get the association for a given owner and attribute name.
- final class betty.model.association.ManyToMany[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],_BidirectionalToManyAssociation
[_OwnerT
,_AssociateT
]A bidirectional many-to-many entity type association.
- final class betty.model.association.ManyToOne[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],_BidirectionalToOneAssociation
[_OwnerT
,_AssociateT
]A bidirectional many-to-one entity type association.
- final class betty.model.association.OneToMany[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],_BidirectionalToManyAssociation
[_OwnerT
,_AssociateT
]A bidirectional one-to-many entity type association.
- final class betty.model.association.OneToOne[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],_BidirectionalToOneAssociation
[_OwnerT
,_AssociateT
]A bidirectional one-to-one entity type association.
- final class betty.model.association.ToMany[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],ToManyAssociation
[_OwnerT
,_AssociateT
]A unidirectional to-many entity type association.
- class betty.model.association.ToManyAssociation[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],Association
[_OwnerT
,_AssociateT
]A to-many entity type association.
This is internal. It MAY be used anywhere in Betty’s source code, but MUST NOT be used by third-party code.
- final class betty.model.association.ToOne[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],ToOneAssociation
[_OwnerT
,_AssociateT
]A unidirectional to-one entity type association.
- class betty.model.association.ToOneAssociation[source]¶
Bases:
Generic
[_OwnerT
,_AssociateT
],Association
[_OwnerT
,_AssociateT
]A unidirectional to-one entity type association.
This is internal. It MAY be used anywhere in Betty’s source code, but MUST NOT be used by third-party code.