class documentation

class CollectionAdapter: (source)

View In Hierarchy

Bridges between the ORM and arbitrary Python collections. Proxies base-level collection operations (append, remove, iterate) to the underlying Python collection, and emits add/remove events for entities entering or leaving the collection. The ORM uses :class:`.CollectionAdapter` exclusively for interaction with entity collections.

Method __bool__ Undocumented
Method __getstate__ Undocumented
Method __init__ Undocumented
Method __iter__ Iterate over entities in the collection.
Method __len__ Count entities in the collection.
Method __setstate__ Undocumented
Method append_multiple_without_event Add or restore an entity to the collection, firing no events.
Method append_with_event Add an entity to the collection, firing mutation events.
Method append_without_event Add or restore an entity to the collection, firing no events.
Method bulk_appender Undocumented
Method bulk_remover Undocumented
Method clear_with_event Empty the collection, firing a mutation event for each entity.
Method clear_without_event Empty the collection, firing no events.
Method fire_append_event Notify that a entity has entered the collection.
Method fire_append_wo_mutation_event Notify that a entity is entering the collection but is already present.
Method fire_pre_remove_event Notify that an entity is about to be removed from the collection.
Method fire_remove_event Notify that a entity has been removed from the collection.
Method remove_with_event Remove an entity from the collection, firing mutation events.
Method remove_without_event Remove an entity from the collection, firing no events.
Class Variable __slots__ Undocumented
Instance Variable attr Undocumented
Instance Variable empty Undocumented
Instance Variable invalidated Undocumented
Instance Variable owner_state Undocumented
Property data The entity collection being adapted.
Method _refuse_empty Undocumented
Method _reset_empty Undocumented
Method _set_empty Undocumented
Method _warn_invalidated Undocumented
Instance Variable _converter Undocumented
Instance Variable _data Undocumented
Instance Variable _key Undocumented
Property _referenced_by_owner return True if the owner state still refers to this collection.
def __bool__(self): (source)

Undocumented

def __getstate__(self): (source)

Undocumented

Undocumented

def __iter__(self): (source)

Iterate over entities in the collection.

def __len__(self): (source)

Count entities in the collection.

def __setstate__(self, d): (source)

Undocumented

def append_multiple_without_event(self, items: Iterable[Any]): (source)

Add or restore an entity to the collection, firing no events.

def append_with_event(self, item: Any, initiator: Optional[AttributeEventToken] = None): (source)

Add an entity to the collection, firing mutation events.

def append_without_event(self, item: Any): (source)

Add or restore an entity to the collection, firing no events.

def bulk_appender(self): (source)

Undocumented

def bulk_remover(self): (source)

Undocumented

def clear_with_event(self, initiator: Optional[AttributeEventToken] = None): (source)

Empty the collection, firing a mutation event for each entity.

def clear_without_event(self): (source)

Empty the collection, firing no events.

def fire_append_event(self, item, initiator=None, key=NO_KEY): (source)

Notify that a entity has entered the collection. Initiator is a token owned by the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation.

def fire_append_wo_mutation_event(self, item, initiator=None, key=NO_KEY): (source)

Notify that a entity is entering the collection but is already present. Initiator is a token owned by the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation. .. versionadded:: 1.4.15

def fire_pre_remove_event(self, initiator=None, key=NO_KEY): (source)

Notify that an entity is about to be removed from the collection. Only called if the entity cannot be removed after calling fire_remove_event().

def fire_remove_event(self, item, initiator=None, key=NO_KEY): (source)

Notify that a entity has been removed from the collection. Initiator is the InstrumentedAttribute that initiated the membership mutation, and should be left as None unless you are passing along an initiator value from a chained operation.

def remove_with_event(self, item: Any, initiator: Optional[AttributeEventToken] = None): (source)

Remove an entity from the collection, firing mutation events.

def remove_without_event(self, item: Any): (source)

Remove an entity from the collection, firing no events.

__slots__: tuple[str, ...] = (source)

Undocumented

Undocumented

Undocumented

invalidated = (source)

Undocumented

owner_state = (source)

Undocumented

The entity collection being adapted.

def _refuse_empty(self) -> NoReturn: (source)

Undocumented

def _reset_empty(self): (source)

Undocumented

def _set_empty(self, user_data): (source)

Undocumented

def _warn_invalidated(self): (source)

Undocumented

_converter = (source)

Undocumented

Undocumented

Undocumented

@property
_referenced_by_owner: bool = (source)

return True if the owner state still refers to this collection. This will return False within a bulk replace operation, where this collection is the one being replaced.