class documentation

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 __init__ Construct an AttributeImpl.
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 collection_factory Undocumented
Instance Variable copy Undocumented
Method __copy Undocumented
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
Instance Variable _append_token Undocumented
Instance Variable _bulk_replace_token Undocumented
Instance Variable _duck_typed_as Undocumented
Instance Variable _remove_token Undocumented

Inherited from HasCollectionAdapter:

Class Variable _is_has_collection_adapter Undocumented

Inherited from AttributeImpl (via HasCollectionAdapter):

Method __str__ Undocumented
Method get Retrieve a value from the given object. If a callable is assembled on this object's attribute, and passive is False, the callable will be executed and the resulting value will be set as the new value for this attribute.
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 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
Method _fire_loader_callables Undocumented
Method _get_active_history Backwards compat for impl.active_history
Method _set_active_history Undocumented
Class Variable _replace_token Undocumented
Instance Variable _deferred_history Undocumented
Instance Variable _modified_token Undocumented
def __init__(self, class_, key, callable_, dispatch, typecallable=None, trackparent=False, copy_function=None, compare_function=None, **kwargs): (source)

Construct an AttributeImpl. :param \class_: associated class :param key: string name of the attribute :param \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. :param trackparent: if True, attempt to track if an instance has a parent attached to it via this attribute. :param compare_function: a function that compares two values which are normally assignable to this attribute. :param active_history: indicates that get_history() should always return the "old" value, even if it means executing a lazy callable upon attribute change. :param parent_token: Usually 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. :param load_on_unexpire: if 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. :param send_modified_events: if 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 append(self, state: InstanceState[Any], dict_: _InstanceDict, value: Any, initiator: Optional[AttributeEventToken], passive: PassiveFlag = PASSIVE_OFF): (source)
def fire_append_event(self, state: InstanceState[Any], dict_: _InstanceDict, value: _T, initiator: Optional[AttributeEventToken], key: Optional[Any]) -> _T: (source)

Undocumented

def fire_append_wo_mutation_event(self, state: InstanceState[Any], dict_: _InstanceDict, value: _T, initiator: Optional[AttributeEventToken], key: Optional[Any]) -> _T: (source)

Undocumented

def fire_pre_remove_event(self, state: InstanceState[Any], dict_: _InstanceDict, initiator: Optional[AttributeEventToken], key: Optional[Any]): (source)

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: InstanceState[Any], dict_: _InstanceDict, value: Any, initiator: Optional[AttributeEventToken], key: Optional[Any]): (source)

Undocumented

def get_all_pending(self, state: InstanceState[Any], dict_: _InstanceDict, passive: PassiveFlag = PASSIVE_NO_INITIALIZE) -> _AllPendingType: (source)

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

@overload
def get_collection(self, state: InstanceState[Any], dict_: _InstanceDict, user_data: Literal[None] = ..., passive: Literal[PassiveFlag.PASSIVE_OFF] = ...) -> CollectionAdapter:
@overload
def get_collection(self, state: InstanceState[Any], dict_: _InstanceDict, user_data: _AdaptedCollectionProtocol = ..., passive: PassiveFlag = ...) -> CollectionAdapter:
@overload
def get_collection(self, state: InstanceState[Any], dict_: _InstanceDict, user_data: Optional[_AdaptedCollectionProtocol] = ..., passive: PassiveFlag = PASSIVE_OFF) -> Union[Literal[LoaderCallableStatus.PASSIVE_NO_RESULT], CollectionAdapter]:
(source)

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 pop(self, state: InstanceState[Any], dict_: _InstanceDict, value: Any, initiator: Optional[AttributeEventToken], passive: PassiveFlag = PASSIVE_OFF): (source)
def remove(self, state: InstanceState[Any], dict_: _InstanceDict, value: Any, initiator: Optional[AttributeEventToken], passive: PassiveFlag = PASSIVE_OFF): (source)
def set(self, state: InstanceState[Any], dict_: _InstanceDict, value: Any, initiator: Optional[AttributeEventToken] = None, passive: PassiveFlag = PassiveFlag.PASSIVE_OFF, check_old: Any = None, pop: bool = False, _adapt: bool = True): (source)
def set_committed_value(self, state: InstanceState[Any], dict_: _InstanceDict, value: Any) -> _AdaptedCollectionProtocol: (source)

Set an attribute value on the given instance and 'commit' it.

collection_factory = (source)

Undocumented

Undocumented

def __copy(self, item): (source)

Undocumented

def _default_value(self, state: InstanceState[Any], dict_: _InstanceDict) -> _AdaptedCollectionProtocol: (source)

Produce an empty collection for an un-initialized attribute

def _dispose_previous_collection(self, state: InstanceState[Any], collection: _AdaptedCollectionProtocol, adapter: CollectionAdapter, fire_event: bool): (source)
def _initialize_collection(self, state: InstanceState[Any]) -> Tuple[CollectionAdapter, _AdaptedCollectionProtocol]: (source)

Undocumented

def _invalidate_collection(self, collection: _AdaptedCollectionProtocol): (source)

Undocumented

_bulk_replace_token = (source)

Undocumented

_duck_typed_as = (source)

Undocumented