class documentation

class CollectionAttributeImpl(AttributeImpl):

View In Hierarchy

A collection-holding attribute that instruments changes in membership.

Only handles collections of instrumented objects.

InstrumentedCollectionAttribute holds an arbitrary, user-specified container object (defaulting to a list) and brokers access to the CollectionAdapter, a "view" onto that object that presents consistent bag semantics to the orm layer independent of the user data implementation.

Method __copy Undocumented
Method __init__ Construct an AttributeImpl.
Method ​_default​_value Produce an empty collection for an un-initialized attribute
Method ​_dispose​_previous​_collection Undocumented
Method ​_initialize​_collection Undocumented
Method ​_invalidate​_collection Undocumented
Method append Undocumented
Method delete Undocumented
Method fire​_append​_event Undocumented
Method fire​_append​_wo​_mutation​_event Undocumented
Method fire​_pre​_remove​_event A special event used for pop() operations.
Method fire​_remove​_event Undocumented
Method get​_all​_pending Return a list of tuples of (state, obj) for all objects in this attribute's current state + history.
Method get​_collection Retrieve the CollectionAdapter associated with the given state.
Method get​_history Undocumented
Method pop Undocumented
Method remove Undocumented
Method set Undocumented
Method set​_committed​_value Set an attribute value on the given instance and 'commit' it.
Class Variable __slots__ Undocumented
Class Variable collection Undocumented
Class Variable default​_accepts​_scalar​_loader Undocumented
Class Variable dynamic Undocumented
Class Variable supports​_population Undocumented
Class Variable uses​_objects Undocumented
Instance Variable ​_append​_token Undocumented
Instance Variable ​_bulk​_replace​_token Undocumented
Instance Variable ​_duck​_typed​_as Undocumented
Instance Variable ​_remove​_token Undocumented
Instance Variable collection​_factory Undocumented
Instance Variable copy Undocumented

Inherited from AttributeImpl:

Method __str__ Undocumented
Method ​_fire​_loader​_callables Undocumented
Method ​_get​_active​_history Backwards compat for impl.active_history
Method ​_set​_active​_history Undocumented
Method get No summary
Method get​_committed​_value return the unchanged value of this attribute
Method hasparent Return the boolean value of a hasparent flag attached to the given state.
Method sethasparent Set a boolean flag on the given item corresponding to whether or not it is attached to a parent object via the attribute represented by this InstrumentedAttribute.
Class Variable active​_history Undocumented
Instance Variable ​_deferred​_history Undocumented
Instance Variable ​_modified​_token Undocumented
Instance Variable accepts​_scalar​_loader Undocumented
Instance Variable callable​_ Undocumented
Instance Variable class​_ Undocumented
Instance Variable dispatch Undocumented
Instance Variable is​_equal Undocumented
Instance Variable key Undocumented
Instance Variable load​_on​_unexpire Undocumented
Instance Variable parent​_token Undocumented
Instance Variable send​_modified​_events Undocumented
Instance Variable trackparent Undocumented
def __copy(self, item):

Undocumented

def __init__(self, class_, key, callable_, dispatch, typecallable=None, trackparent=False, copy_function=None, compare_function=None, **kwargs):
Construct an AttributeImpl.
Parameters
class​_associated class
keystring name of the attribute
callable​_optional function which generates a callable based on a parent instance, which produces the "default" values for a scalar or collection attribute when it's first accessed, if not present already.
dispatchUndocumented
typecallableUndocumented
trackparentif True, attempt to track if an instance has a parent attached to it via this attribute.
copy​_functionUndocumented
compare​_functiona function that compares two values which are normally assignable to this attribute.
**kwargsUndocumented
active​_historyindicates that get_history() should always return the "old" value, even if it means executing a lazy callable upon attribute change.
parent​_tokenUsually references the MapperProperty, used as a key for the hasparent() function to identify an "owning" attribute. Allows multiple AttributeImpls to all match a single owner attribute.
load​_on​_unexpireif False, don't include this attribute in a load-on-expired operation, i.e. the "expired_attribute_loader" process. The attribute can still be in the "expired" list and be considered to be "expired". Previously, this flag was called "expire_missing" and is only used by a deferred column attribute.
send​_modified​_eventsif False, the InstanceState._modified_event method will have no effect; this means the attribute will never show up as changed in a history entry.
def _default_value(self, state, dict_):
Produce an empty collection for an un-initialized attribute
def _dispose_previous_collection(self, state, collection, adapter, fire_event):

Undocumented

def _initialize_collection(self, state):

Undocumented

def _invalidate_collection(self, collection):

Undocumented

def append(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
def delete(self, state, dict_):

Undocumented

def fire_append_event(self, state, dict_, value, initiator):

Undocumented

def fire_append_wo_mutation_event(self, state, dict_, value, initiator):

Undocumented

def fire_pre_remove_event(self, state, dict_, initiator):

A special event used for pop() operations.

The "remove" event needs to have the item to be removed passed to it, which in the case of pop from a set, we don't have a way to access the item before the operation. the event is used for all pop() operations (even though set.pop is the one where it is really needed).

def fire_remove_event(self, state, dict_, value, initiator):

Undocumented

def get_all_pending(self, state, dict_, passive=PASSIVE_NO_INITIALIZE):

Return a list of tuples of (state, obj) for all objects in this attribute's current state + history.

Only applies to object-based attributes.

This is an inlining of existing functionality which roughly corresponds to:

get_state_history(
state, key, passive=PASSIVE_NO_INITIALIZE).sum()
def get_collection(self, state, dict_, user_data=None, passive=PASSIVE_OFF):

Retrieve the CollectionAdapter associated with the given state.

if user_data is None, retrieves it from the state using normal "get()" rules, which will fire lazy callables or return the "empty" collection value.

def get_history(self, state, dict_, passive=PASSIVE_OFF):
def pop(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
def remove(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
def set(self, state, dict_, value, initiator=None, passive=PASSIVE_OFF, check_old=None, pop=False, _adapt=True):
def set_committed_value(self, state, dict_, value):
Set an attribute value on the given instance and 'commit' it.
__slots__: tuple[str, ...] =
collection: bool =

Undocumented

default_accepts_scalar_loader: bool =

Undocumented

dynamic: bool =

Undocumented

supports_population: bool =

Undocumented

uses_objects: bool =

Undocumented

_append_token =

Undocumented

_bulk_replace_token =

Undocumented

_duck_typed_as =

Undocumented

_remove_token =

Undocumented

collection_factory =

Undocumented

copy =

Undocumented