betty.attrs.collection_attr module

Attributes that store collections of data in instance attributes.

final class betty.attrs.collection_attr.CollectionAttrAttr

Bases: OwnerAttr, Generic

An object attribute that stores its collection of data on owner instances.

__init__(data: ResolvableDataDefinition[CollectionDefinition[MutableCollectionT, ValuesSetT, Element[Any]]], *, description: ResolvableLocalizable | None = None, label: ResolvableLocalizable | None = None, omit_dump: Callable[[MutableCollectionT], bool] | Callable[[OwnerT, MutableCollectionT], bool] | None = None, omit_load: bool = False)
default(default: Callable[[], ValuesSetT] | Callable[[OwnerT], ValuesSetT]) OwnerAttr[OwnerT, MutableCollectionT, ValuesSetT]

Create a new attribute that proxies this one, and sets a default value.

get(owner: OwnerT, /) MutableCollectionT

Get the property value from the owner.

init_owner(owner: OwnerT, /) None

Initialize the property on an owner.

set(owner: OwnerT, value: ValuesSetT, /) None

Set the value on the owner.

Raises:

NotSettable