"""Return a :class:`.History` record for the given object
and attribute key.
+ This is the **pre-flush** history for a given attribute, which is
+ reset each time the :class:`.Session` flushes changes to the
+ current database transaction.
+
+ .. note::
+
+ Prefer to use the :attr:`.AttributeState.history` and
+ :meth:`.AttributeState.load_history` accessors to retrieve the
+ :class:`.History` for instance attributes.
+
+
:param obj: an object whose class is instrumented by the
attributes package.
:attr:`.PASSIVE_OFF` indicating all necessary SQL
should be emitted.
+ .. seealso::
+
+ :attr:`.AttributeState.history`
+
+ :meth:`.AttributeState.load_history` - retrieve history
+ using loader callables if the value is not locally present.
+
"""
if passive is True:
util.warn_deprecated(
@property
def history(self):
- """Return the current pre-flush change history for
+ """Return the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.
This method will **not** emit loader callables if the value of the
attribute is unloaded.
+ .. note::
+
+ The attribute history system tracks changes on a **per flush
+ basis**. Each time the :class:`.Session` is flushed, the history
+ of each attribute is reset to empty. The :class:`.Session` by
+ default autoflushes each time a :class:`.Query` is invoked. For
+ options on how to control this, see :ref:`session_flushing`.
+
+
.. seealso::
:meth:`.AttributeState.load_history` - retrieve history
return self.state.get_history(self.key, PASSIVE_NO_INITIALIZE)
def load_history(self):
- """Return the current pre-flush change history for
+ """Return the current **pre-flush** change history for
this attribute, via the :class:`.History` interface.
This method **will** emit loader callables if the value of the
attribute is unloaded.
+ .. note::
+
+ The attribute history system tracks changes on a **per flush
+ basis**. Each time the :class:`.Session` is flushed, the history
+ of each attribute is reset to empty. The :class:`.Session` by
+ default autoflushes each time a :class:`.Query` is invoked. For
+ options on how to control this, see :ref:`session_flushing`.
+
.. seealso::
:attr:`.AttributeState.history`