betty.collections.to_many module

Collections for to-many associations.

final class betty.collections.to_many.ToManyCollection

Bases: MutableCollection, Sequence, Generic

A collection of *-to-many associates.

__init__(owner: OwnerT, association: ToMany[OwnerT, AssociateT], *associates: Associate[OwnerT, AssociateT])
add(*associates: Associate[OwnerT, AssociateT]) None

Add the given associates.

assert_resolved() None

Assert that all associates in this collection have been resolved.

associate(*associates: AssociateT) None

Add associates.

This behaves similar to :py:meth:betty.association.Association.associate` and MUST only be called by betty.associations.to_many.ToMany.

clear() None

Remove all values from the collection.

disassociate(*associates: AssociateT) None

Remove associates.

This behaves similar to :py:meth:betty.association.Association.disassociate` and MUST only be called by betty.associations.to_many.ToMany.

remove(*associates: AssociateT) None

Remove the given associates.

replace(*associates: Associate[OwnerT, AssociateT]) None

Replace all associates with the given ones.

resolve(project: Project, /) None

Resolve all associates in this collection.