class documentation

class AttributeImpl(object):

Known subclasses: sqlalchemy.orm.attributes.CollectionAttributeImpl, sqlalchemy.orm.attributes.ScalarAttributeImpl, sqlalchemy.orm.dynamic.DynamicAttributeImpl

View In Hierarchy

internal implementation for instrumented attributes.
Method __init__ Construct an AttributeImpl.
Method __str__ Undocumented
Method ​_default​_value Produce an empty value for an uninitialized scalar attribute.
Method ​_fire​_loader​_callables Undocumented
Method ​_get​_active​_history Backwards compat for impl.active_history
Method ​_set​_active​_history Undocumented
Method append Undocumented
Method get No summary
Method get​_all​_pending Return a list of tuples of (state, obj) for all objects in this attribute's current state + history.
Method get​_committed​_value return the unchanged value of this attribute
Method get​_history Undocumented
Method hasparent Return the boolean value of a hasparent flag attached to the given state.
Method pop Undocumented
Method remove Undocumented
Method set Undocumented
Method set​_committed​_value set an attribute value on the given instance and 'commit' it.
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 __slots__ Undocumented
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 __init__(self, class_, key, callable_, dispatch, trackparent=False, compare_function=None, active_history=False, parent_token=None, load_on_unexpire=True, send_modified_events=True, accepts_scalar_loader=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
trackparentif True, attempt to track if an instance has a parent attached to it via this attribute.
compare​_functiona function that compares two values which are normally assignable to this attribute.
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.
accepts​_scalar​_loaderUndocumented
**kwargsUndocumented
def __str__(self):

Undocumented

def _default_value(self, state, dict_):
Produce an empty value for an uninitialized scalar attribute.
def _fire_loader_callables(self, state, key, passive):

Undocumented

def _get_active_history(self):
Backwards compat for impl.active_history
def _set_active_history(self, value):

Undocumented

def append(self, state, dict_, value, initiator, passive=PASSIVE_OFF):
def get(self, state, dict_, passive=PASSIVE_OFF):
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.
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_committed_value(self, state, dict_, passive=PASSIVE_OFF):
return the unchanged value of this attribute
def hasparent(self, state, optimistic=False):

Return the boolean value of a hasparent flag attached to the given state.

The optimistic flag determines what the default return value should be if no hasparent flag can be located.

As this function is used to determine if an instance is an orphan, instances that were loaded from storage should be assumed to not be orphans, until a True/False value for this flag is set.

An instance attribute that is loaded by a callable function will also not have a hasparent flag.

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, passive=PASSIVE_OFF, check_old=None, pop=False):
def set_committed_value(self, state, dict_, value):
set an attribute value on the given instance and 'commit' it.
def sethasparent(self, state, parent_state, value):
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.
active_history =

Undocumented

_deferred_history =

Undocumented

_modified_token =

Undocumented

accepts_scalar_loader =

Undocumented

callable_ =

Undocumented

class_ =

Undocumented

dispatch =

Undocumented

is_equal =

Undocumented

key =

Undocumented

load_on_unexpire =

Undocumented

parent_token =

Undocumented

send_modified_events =

Undocumented

trackparent =

Undocumented