class documentation

class CollectionAdapter(object):

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 .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 ​_refuse​_empty Undocumented
Method ​_reset​_empty Undocumented
Method ​_set​_empty Undocumented
Method ​_warn​_invalidated 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 ​_converter Undocumented
Instance Variable ​_data Undocumented
Instance Variable ​_key Undocumented
Instance Variable attr Undocumented
Instance Variable empty Undocumented
Instance Variable invalidated Undocumented
Instance Variable owner​_state Undocumented
Property ​_referenced​_by​_owner return True if the owner state still refers to this collection.
Property data The entity collection being adapted.
def __bool__(self):

Undocumented

def __getstate__(self):

Undocumented

def __init__(self, attr, owner_state, data):

Undocumented

def __iter__(self):
Iterate over entities in the collection.
def __len__(self):
Count entities in the collection.
def __setstate__(self, d):

Undocumented

def _refuse_empty(self):

Undocumented

def _reset_empty(self):

Undocumented

def _set_empty(self, user_data):

Undocumented

def _warn_invalidated(self):

Undocumented

def append_multiple_without_event(self, items):
Add or restore an entity to the collection, firing no events.
def append_with_event(self, item, initiator=None):
Add an entity to the collection, firing mutation events.
def append_without_event(self, item):
Add or restore an entity to the collection, firing no events.
def bulk_appender(self):

Undocumented

def bulk_remover(self):

Undocumented

def clear_with_event(self, initiator=None):
Empty the collection, firing a mutation event for each entity.
def clear_without_event(self):
Empty the collection, firing no events.
def fire_append_event(self, item, initiator=None):

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):

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.

New in version 1.4.15.
def fire_pre_remove_event(self, initiator=None):

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):

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, initiator=None):
Remove an entity from the collection, firing mutation events.
def remove_without_event(self, item):
Remove an entity from the collection, firing no events.
__slots__: tuple[str, ...] =

Undocumented

_converter =

Undocumented

_data =

Undocumented

_key =

Undocumented

attr =

Undocumented

empty =

Undocumented

invalidated =

Undocumented

owner_state =

Undocumented

@property
_referenced_by_owner =

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.

@property
data =
The entity collection being adapted.