betty.model.association module¶
Entity associations.
- class betty.model.association.Association[source]¶
Bases:
Generic[_OwnerT,_AssociateT,_AssociationAttrValueT,_AssociationAttrSetT],MutableAttr[Intersection[_OwnerT,Entity],_AssociationAttrValueT,_AssociationAttrSetT]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:
objectInspect any known entity type associations.
- classmethod get_all_associations(owner: type | object) set[Association[Any, Any, Any, Any]][source]¶
Get all associations for an owner.
- classmethod get_associates(owner: _EntityT, association: Association[_EntityT, _AssociateT, Any, Any]) Iterable[_AssociateT][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, Any, 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.
- new_attr(instance: _OwnerT & Entity) EntityCollection[_AssociateT][source]¶
Create a new attribute value.
- class betty.model.association.ToManyAssociation[source]¶
Bases:
Generic[_OwnerT,_AssociateT],Association[_OwnerT,_AssociateT,EntityCollection[_AssociateT],Iterable[Intersection[_AssociateT,Entity]]]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.
- associate(owner: _OwnerT & Entity, associate: _AssociateT & Entity) None[source]¶
Associate two entities.
- 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,Intersection[_AssociateT,Entity] |None,Intersection[_AssociateT,Entity] |None]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.
- associate(owner: _OwnerT & Entity, associate: _AssociateT & Entity) None[source]¶
Associate two entities.