class documentation

class History(util.namedtuple('History', ['added', 'unchanged', 'deleted'])):

View In Hierarchy

A 3-tuple of added, unchanged and deleted values, representing the changes which have occurred on an instrumented attribute.

The easiest way to get a .History object for a particular attribute on an object is to use the _sa.inspect function:

from sqlalchemy import inspect

hist = inspect(myobject).attrs.myattribute.history

Each tuple member is an iterable sequence:

  • added - the collection of items added to the attribute (the first tuple element).
  • unchanged - the collection of items that have not changed on the attribute (the second tuple element).
  • deleted - the collection of items that have been removed from the attribute (the third tuple element).
Class Method from​_collection Undocumented
Class Method from​_object​_attribute Undocumented
Class Method from​_scalar​_attribute Undocumented
Method empty Return True if this .History has no changes and no existing, unchanged state.
Method has​_changes Return True if this .History has changes.
Method non​_added Return a collection of unchanged + deleted.
Method non​_deleted Return a collection of added + unchanged.
Method sum Return a collection of added + unchanged + deleted.
Method __bool__ Undocumented
Method as​_state Undocumented
@classmethod
def from_collection(cls, attribute, state, current):

Undocumented

@classmethod
def from_object_attribute(cls, attribute, state, current, original=_NO_HISTORY):

Undocumented

@classmethod
def from_scalar_attribute(cls, attribute, state, current):

Undocumented

def empty(self):
Return True if this .History has no changes and no existing, unchanged state.
def has_changes(self):
Return True if this .History has changes.
def non_added(self):
Return a collection of unchanged + deleted.
def non_deleted(self):
Return a collection of added + unchanged.
def sum(self):
Return a collection of added + unchanged + deleted.
def __bool__(self):

Undocumented

def as_state(self):

Undocumented