Module Expr Str ImportFrom alias ImportFrom alias alias ImportFrom alias alias alias ImportFrom alias Import alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Return NameLoad Assign NameStore Str Raise Call NameLoad BinOpMod NameLoad TupleLoad NameLoad Call NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr If CompareIsNot NameLoad AttributeLoad NameLoad attr body Return Assign NameStore AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults vararg body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If CompareIsNot NameLoad NameLoad body If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Return NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareIsNot NameLoad NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index Call AttributeLoad NameLoad attr NameLoad If Call NameLoad NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad If CompareIsNot NameLoad NameLoad body If CompareNotIn Str NameLoad body Assign SubscriptStore NameLoad Index Str ListLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareIn Str NameLoad body For NameStore SubscriptLoad NameLoad Index Str body Assign SubscriptStore AttributeLoad NameLoad attr Index Call AttributeLoad NameLoad attr NameLoad decorator_list Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad keyword NameLoad keyword NameLoad decorator_list NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Expr Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str FunctionDef arguments args NameParam NameParam defaults body For NameStore AttributeLoad NameLoad attr body If Call NameLoad AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr decorator_list Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad FunctionDef arguments args NameParam NameParam defaults body For NameStore AttributeLoad NameLoad attr body If CompareIs AttributeLoad SubscriptLoad AttributeLoad NameLoad attr Index Num attr NameLoad body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr decorator_list Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad Return NameLoad decorator_list NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Assign NameStore Call AttributeLoad Call NameLoad NameLoad attr NameLoad For TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call NameLoad NameLoad NameLoad NameLoad decorator_list decorator_list FunctionDef arguments args defaults body FunctionDef arguments args NameParam NameParam defaults body For NameStore AttributeLoad NameLoad attr body If BoolOpAnd Call NameLoad NameLoad Str Call NameLoad AttributeLoad NameLoad attr NameLoad Call NameLoad AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad NameLoad decorator_list If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad Str NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Str NameLoad decorator_list Expr Call NameLoad ClassDef bases NameLoad NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults vararg kwarg body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot Call NameLoad NameLoad NameLoad body If Call NameLoad NameLoad NameLoad body Return Call NameLoad NameLoad Return Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list decorator_list
N/A N/A Provide support for tracking of in-place changes to scalar values,
which are propagated into ORM change events on owning parent objects.

.. versionadded:: 0.7 :mod:`sqlalchemy.ext.mutable` replaces SQLAlchemy's
   legacy approach to in-place mutations of scalar values; see
   :ref:`07_migration_mutation_extension`.

.. _mutable_scalars:

Establishing Mutability on Scalar Column Values
===============================================

A typical example of a "mutable" structure is a Python dictionary.
Following the example introduced in :ref:`types_toplevel`, we
begin with a custom type that marshals Python dictionaries into
JSON strings before being persisted::

    from sqlalchemy.types import TypeDecorator, VARCHAR
    import json

    class JSONEncodedDict(TypeDecorator):
        "Represents an immutable structure as a json-encoded string."

        impl = VARCHAR

        def process_bind_param(self, value, dialect):
            if value is not None:
                value = json.dumps(value)
            return value

        def process_result_value(self, value, dialect):
            if value is not None:
                value = json.loads(value)
            return value

The usage of ``json`` is only for the purposes of example. The
:mod:`sqlalchemy.ext.mutable` extension can be used
with any type whose target Python type may be mutable, including
:class:`.PickleType`, :class:`.postgresql.ARRAY`, etc.

When using the :mod:`sqlalchemy.ext.mutable` extension, the value itself
tracks all parents which reference it.  Below, we illustrate the a simple
version of the :class:`.MutableDict` dictionary object, which applies
the :class:`.Mutable` mixin to a plain Python dictionary::

    from sqlalchemy.ext.mutable import Mutable

    class MutableDict(Mutable, dict):
        @classmethod
        def coerce(cls, key, value):
            "Convert plain dictionaries to MutableDict."

            if not isinstance(value, MutableDict):
                if isinstance(value, dict):
                    return MutableDict(value)

                # this call will raise ValueError
                return Mutable.coerce(key, value)
            else:
                return value

        def __setitem__(self, key, value):
            "Detect dictionary set events and emit change events."

            dict.__setitem__(self, key, value)
            self.changed()

        def __delitem__(self, key):
            "Detect dictionary del events and emit change events."

            dict.__delitem__(self, key)
            self.changed()

The above dictionary class takes the approach of subclassing the Python
built-in ``dict`` to produce a dict
subclass which routes all mutation events through ``__setitem__``.  There are
variants on this approach, such as subclassing ``UserDict.UserDict`` or
``collections.MutableMapping``; the part that's important to this example is
that the :meth:`.Mutable.changed` method is called whenever an in-place
change to the datastructure takes place.

We also redefine the :meth:`.Mutable.coerce` method which will be used to
convert any values that are not instances of ``MutableDict``, such
as the plain dictionaries returned by the ``json`` module, into the
appropriate type.  Defining this method is optional; we could just as well
created our ``JSONEncodedDict`` such that it always returns an instance
of ``MutableDict``, and additionally ensured that all calling code
uses ``MutableDict`` explicitly.  When :meth:`.Mutable.coerce` is not
overridden, any values applied to a parent object which are not instances
of the mutable type will raise a ``ValueError``.

Our new ``MutableDict`` type offers a class method
:meth:`~.Mutable.as_mutable` which we can use within column metadata
to associate with types. This method grabs the given type object or
class and associates a listener that will detect all future mappings
of this type, applying event listening instrumentation to the mapped
attribute. Such as, with classical table metadata::

    from sqlalchemy import Table, Column, Integer

    my_data = Table('my_data', metadata,
        Column('id', Integer, primary_key=True),
        Column('data', MutableDict.as_mutable(JSONEncodedDict))
    )

Above, :meth:`~.Mutable.as_mutable` returns an instance of ``JSONEncodedDict``
(if the type object was not an instance already), which will intercept any
attributes which are mapped against this type.  Below we establish a simple
mapping against the ``my_data`` table::

    from sqlalchemy import mapper

    class MyDataClass(object):
        pass

    # associates mutation listeners with MyDataClass.data
    mapper(MyDataClass, my_data)

The ``MyDataClass.data`` member will now be notified of in place changes
to its value.

There's no difference in usage when using declarative::

    from sqlalchemy.ext.declarative import declarative_base

    Base = declarative_base()

    class MyDataClass(Base):
        __tablename__ = 'my_data'
        id = Column(Integer, primary_key=True)
        data = Column(MutableDict.as_mutable(JSONEncodedDict))

Any in-place changes to the ``MyDataClass.data`` member
will flag the attribute as "dirty" on the parent object::

    >>> from sqlalchemy.orm import Session

    >>> sess = Session()
    >>> m1 = MyDataClass(data={'value1':'foo'})
    >>> sess.add(m1)
    >>> sess.commit()

    >>> m1.data['value1'] = 'bar'
    >>> assert m1 in sess.dirty
    True

The ``MutableDict`` can be associated with all future instances
of ``JSONEncodedDict`` in one step, using
:meth:`~.Mutable.associate_with`.  This is similar to
:meth:`~.Mutable.as_mutable` except it will intercept all occurrences
of ``MutableDict`` in all mappings unconditionally, without
the need to declare it individually::

    MutableDict.associate_with(JSONEncodedDict)

    class MyDataClass(Base):
        __tablename__ = 'my_data'
        id = Column(Integer, primary_key=True)
        data = Column(JSONEncodedDict)


Supporting Pickling
--------------------

The key to the :mod:`sqlalchemy.ext.mutable` extension relies upon the
placement of a ``weakref.WeakKeyDictionary`` upon the value object, which
stores a mapping of parent mapped objects keyed to the attribute name under
which they are associated with this value. ``WeakKeyDictionary`` objects are
not picklable, due to the fact that they contain weakrefs and function
callbacks. In our case, this is a good thing, since if this dictionary were
picklable, it could lead to an excessively large pickle size for our value
objects that are pickled by themselves outside of the context of the parent.
The developer responsibility here is only to provide a ``__getstate__`` method
that excludes the :meth:`~MutableBase._parents` collection from the pickle
stream::

    class MyMutableType(Mutable):
        def __getstate__(self):
            d = self.__dict__.copy()
            d.pop('_parents', None)
            return d

With our dictionary example, we need to return the contents of the dict itself
(and also restore them on __setstate__)::

    class MutableDict(Mutable, dict):
        # ....

        def __getstate__(self):
            return dict(self)

        def __setstate__(self, state):
            self.update(state)

In the case that our mutable value object is pickled as it is attached to one
or more parent objects that are also part of the pickle, the :class:`.Mutable`
mixin will re-establish the :attr:`.Mutable._parents` collection on each value
object as the owning parents themselves are unpickled.

.. _mutable_composites:

Establishing Mutability on Composites
=====================================

Composites are a special ORM feature which allow a single scalar attribute to
be assigned an object value which represents information "composed" from one
or more columns from the underlying mapped table. The usual example is that of
a geometric "point", and is introduced in :ref:`mapper_composite`.

.. versionchanged:: 0.7
    The internals of :func:`.orm.composite` have been
    greatly simplified and in-place mutation detection is no longer enabled by
    default; instead, the user-defined value must detect changes on its own and
    propagate them to all owning parents. The :mod:`sqlalchemy.ext.mutable`
    extension provides the helper class :class:`.MutableComposite`, which is a
    slight variant on the :class:`.Mutable` class.

As is the case with :class:`.Mutable`, the user-defined composite class
subclasses :class:`.MutableComposite` as a mixin, and detects and delivers
change events to its parents via the :meth:`.MutableComposite.changed` method.
In the case of a composite class, the detection is usually via the usage of
Python descriptors (i.e. ``@property``), or alternatively via the special
Python method ``__setattr__()``. Below we expand upon the ``Point`` class
introduced in :ref:`mapper_composite` to subclass :class:`.MutableComposite`
and to also route attribute set events via ``__setattr__`` to the
:meth:`.MutableComposite.changed` method::

    from sqlalchemy.ext.mutable import MutableComposite

    class Point(MutableComposite):
        def __init__(self, x, y):
            self.x = x
            self.y = y

        def __setattr__(self, key, value):
            "Intercept set events"

            # set the attribute
            object.__setattr__(self, key, value)

            # alert all parents to the change
            self.changed()

        def __composite_values__(self):
            return self.x, self.y

        def __eq__(self, other):
            return isinstance(other, Point) and \
                other.x == self.x and \
                other.y == self.y

        def __ne__(self, other):
            return not self.__eq__(other)

The :class:`.MutableComposite` class uses a Python metaclass to automatically
establish listeners for any usage of :func:`.orm.composite` that specifies our
``Point`` type. Below, when ``Point`` is mapped to the ``Vertex`` class,
listeners are established which will route change events from ``Point``
objects to each of the ``Vertex.start`` and ``Vertex.end`` attributes::

    from sqlalchemy.orm import composite, mapper
    from sqlalchemy import Table, Column

    vertices = Table('vertices', metadata,
        Column('id', Integer, primary_key=True),
        Column('x1', Integer),
        Column('y1', Integer),
        Column('x2', Integer),
        Column('y2', Integer),
        )

    class Vertex(object):
        pass

    mapper(Vertex, vertices, properties={
        'start': composite(Point, vertices.c.x1, vertices.c.y1),
        'end': composite(Point, vertices.c.x2, vertices.c.y2)
    })

Any in-place changes to the ``Vertex.start`` or ``Vertex.end`` members
will flag the attribute as "dirty" on the parent object::

    >>> from sqlalchemy.orm import Session

    >>> sess = Session()
    >>> v1 = Vertex(start=Point(3, 4), end=Point(12, 15))
    >>> sess.add(v1)
    >>> sess.commit()

    >>> v1.end.x = 8
    >>> assert v1 in sess.dirty
    True

Coercing Mutable Composites
---------------------------

The :meth:`.MutableBase.coerce` method is also supported on composite types.
In the case of :class:`.MutableComposite`, the :meth:`.MutableBase.coerce`
method is only called for attribute set operations, not load operations.
Overriding the :meth:`.MutableBase.coerce` method is essentially equivalent
to using a :func:`.validates` validation routine for all attributes which
make use of the custom composite type::

    class Point(MutableComposite):
        # other Point methods
        # ...

        def coerce(cls, key, value):
            if isinstance(value, tuple):
                value = Point(*value)
            elif not isinstance(value, Point):
                raise ValueError("tuple or Point expected")
            return value

.. versionadded:: 0.7.10,0.8.0b2
    Support for the :meth:`.MutableBase.coerce` method in conjunction with
    objects of type :class:`.MutableComposite`.

Supporting Pickling
--------------------

As is the case with :class:`.Mutable`, the :class:`.MutableComposite` helper
class uses a ``weakref.WeakKeyDictionary`` available via the
:meth:`MutableBase._parents` attribute which isn't picklable. If we need to
pickle instances of ``Point`` or its owning class ``Vertex``, we at least need
to define a ``__getstate__`` that doesn't include the ``_parents`` dictionary.
Below we define both a ``__getstate__`` and a ``__setstate__`` that package up
the minimal form of our ``Point`` class::

    class Point(MutableComposite):
        # ...

        def __getstate__(self):
            return self.x, self.y

        def __setstate__(self, state):
            self.x, self.y = state

As with :class:`.Mutable`, the :class:`.MutableComposite` augments the
pickling process of the parent's object-relational state so that the
:meth:`MutableBase._parents` collection is restored to all ``Point`` objects.

 orm.attributes flag_modified N/A event types orm mapper object_mapper Mapper util memoized_property N/A weakref MutableBase N/A object N/A N/A Common base class to :class:`.Mutable`
    and :class:`.MutableComposite`.

     _parents N/A N/A self N/A N/A N/A Dictionary of parent object->attribute name on the parent.

        This attribute is a so-called "memoized" property.  It initializes
        itself with a new ``weakref.WeakKeyDictionary`` the first time
        it is accessed, returning the same object upon subsequent access.

         N/A N/A N/A weakref WeakKeyDictionary N/A memoized_property coerce N/A N/A cls key value N/A N/A N/A Given a value, coerce it into the target type.

        Can be overridden by custom subclasses to coerce incoming
        data into a particular type.

        By default, raises ``ValueError``.

        This method is called in different scenarios depending on if
        the parent class is of type :class:`.Mutable` or of type
        :class:`.MutableComposite`.  In the case of the former, it is called
        for both attribute-set operations as well as during ORM loading
        operations.  For the latter, it is only called during attribute-set
        operations; the mechanics of the :func:`.composite` construct
        handle coercion during load operations.


        :param key: string name of the ORM-mapped attribute being set.
        :param value: the incoming value.
        :return: the method should return the coerced value, or raise
         ``ValueError`` if the coercion cannot be completed.

         N/A N/A value None N/A N/A None N/A msg Attribute '%s' does not accept objects of type %s N/A N/A ValueError N/A msg N/A key N/A type value N/A classmethod _listen_on_attribute N/A N/A cls attribute coerce parent_cls N/A N/A N/A Establish this type as a mutation listener for the given
        mapped descriptor.

         N/A key N/A attribute key N/A N/A parent_cls N/A attribute class_ N/A N/A N/A parent_cls N/A attribute class_ load N/A N/A state N/A args N/A N/A Listen for objects loaded or refreshed.

            Wrap the target data member's value with
            ``Mutable``.

             N/A val N/A N/A N/A state dict get key None N/A N/A val None N/A N/A coerce N/A N/A val N/A N/A cls coerce key val N/A N/A N/A state dict N/A key val N/A N/A N/A val _parents N/A N/A N/A state obj key N/A set N/A N/A target value oldvalue initiator N/A N/A N/A Listen for set/replace events on the target
            data member.

            Establish a weak reference to the parent object
            on the incoming value, remove it for the one
            outgoing.

             N/A N/A value oldvalue N/A N/A value N/A N/A N/A isinstance value cls N/A N/A value N/A N/A cls coerce key value N/A N/A value None N/A N/A N/A N/A value _parents N/A N/A N/A target obj key N/A N/A isinstance oldvalue cls N/A N/A N/A N/A N/A oldvalue _parents pop N/A N/A target obj None N/A value N/A pickle N/A N/A state state_dict N/A N/A N/A val N/A N/A N/A state dict get key None N/A N/A val None N/A N/A N/A ext.mutable.values state_dict N/A N/A N/A state_dict N/A ext.mutable.values N/A N/A N/A N/A N/A state_dict N/A ext.mutable.values append val N/A unpickle N/A N/A state state_dict N/A N/A N/A N/A ext.mutable.values state_dict N/A N/A val N/A state_dict N/A ext.mutable.values N/A N/A N/A N/A val _parents N/A N/A N/A state obj key N/A N/A N/A N/A event listen parent_cls load load raw True propagate True N/A N/A N/A event listen parent_cls refresh load raw True propagate True N/A N/A N/A event listen attribute set set raw True retval True propagate True N/A N/A N/A event listen parent_cls pickle pickle raw True propagate True N/A N/A N/A event listen parent_cls unpickle unpickle raw True propagate True N/A classmethod N/A Mutable N/A MutableBase N/A N/A Mixin that defines transparent propagation of change
    events to a parent object.

    See the example in :ref:`mutable_scalars` for usage information.

     changed N/A N/A self N/A N/A N/A Subclasses should call this method whenever change events occur. N/A N/A parent key N/A N/A N/A self _parents items N/A N/A N/A flag_modified parent key N/A associate_with_attribute N/A N/A cls attribute N/A N/A N/A Establish this type as a mutation listener for the given
        mapped descriptor.

         N/A N/A N/A cls _listen_on_attribute attribute True N/A attribute class_ N/A classmethod associate_with N/A N/A cls sqltype N/A N/A N/A Associate this wrapper with all future mapped columns
        of the given type.

        This is a convenience method that calls
        ``associate_with_attribute`` automatically.

        .. warning::

           The listeners established by this method are *global*
           to all mappers, and are *not* garbage collected.   Only use
           :meth:`.associate_with` for types that are permanent to an
           application, not with ad-hoc types else this will cause unbounded
           growth in memory usage.

         listen_for_type N/A N/A mapper class_ N/A N/A N/A prop N/A mapper column_attrs N/A N/A N/A isinstance N/A N/A N/A prop columns N/A 0 type sqltype N/A N/A N/A N/A cls associate_with_attribute N/A getattr class_ N/A prop key N/A N/A N/A N/A event listen mapper mapper_configured listen_for_type N/A classmethod as_mutable N/A N/A cls sqltype N/A N/A N/A Associate a SQL type with this mutable Python type.

        This establishes listeners that will detect ORM mappings against
        the given type, adding mutation event trackers to those mappings.

        The type is returned, unconditionally as an instance, so that
        :meth:`.as_mutable` can be used inline::

            Table('mytable', metadata,
                Column('id', Integer, primary_key=True),
                Column('data', MyMutableType.as_mutable(PickleType))
            )

        Note that the returned type is always an instance, even if a class
        is given, and that only columns which are declared specifically with
        that type instance receive additional instrumentation.

        To associate a particular mutable type with all occurrences of a
        particular type, use the :meth:`.Mutable.associate_with` classmethod
        of the particular :class:`.Mutable` subclass to establish a global
        association.

        .. warning::

           The listeners established by this method are *global*
           to all mappers, and are *not* garbage collected.   Only use
           :meth:`.as_mutable` for types that are permanent to an application,
           not with ad-hoc types else this will cause unbounded growth
           in memory usage.

         N/A sqltype N/A N/A types to_instance sqltype listen_for_type N/A N/A mapper class_ N/A N/A N/A prop N/A mapper column_attrs N/A N/A N/A N/A N/A N/A prop columns N/A 0 type sqltype N/A N/A N/A N/A cls associate_with_attribute N/A getattr class_ N/A prop key N/A N/A N/A N/A event listen mapper mapper_configured listen_for_type N/A sqltype N/A classmethod N/A MutableComposite N/A MutableBase N/A N/A Mixin that defines transparent propagation of change
    events on a SQLAlchemy "composite" object to its
    owning parent or parents.

    See the example in :ref:`mutable_composites` for usage information.

     changed N/A N/A self N/A N/A N/A Subclasses should call this method whenever change events occur. N/A N/A parent key N/A N/A N/A self _parents items N/A N/A prop N/A N/A N/A object_mapper parent get_property key N/A N/A value attr_name N/A zip N/A N/A self __composite_values__ N/A prop _attribute_keys N/A N/A N/A setattr parent attr_name value N/A N/A _setup_composite_listener N/A N/A N/A N/A _listen_for_type N/A N/A mapper class_ N/A N/A N/A prop N/A mapper iterate_properties N/A N/A N/A N/A hasattr prop composite_class N/A isinstance N/A prop composite_class type N/A issubclass N/A prop composite_class MutableComposite N/A N/A N/A N/A N/A prop composite_class _listen_on_attribute N/A getattr class_ N/A prop key False class_ N/A N/A N/A N/A N/A event contains Mapper mapper_configured _listen_for_type N/A N/A N/A N/A event listen Mapper mapper_configured _listen_for_type N/A N/A N/A _setup_composite_listener MutableDict N/A Mutable dict N/A N/A A dictionary type that implements :class:`.Mutable`.

    .. versionadded:: 0.8

     __setitem__ N/A N/A self key value N/A N/A N/A Detect dictionary set events and emit change events. N/A N/A N/A dict __setitem__ self key value N/A N/A N/A self changed N/A setdefault N/A N/A self key value N/A N/A N/A result N/A N/A dict setdefault self key value N/A N/A N/A self changed N/A result N/A __delitem__ N/A N/A self key N/A N/A N/A Detect dictionary del events and emit change events. N/A N/A N/A dict __delitem__ self key N/A N/A N/A self changed N/A update N/A N/A self N/A a kw N/A N/A N/A N/A dict update self a kw N/A N/A N/A self changed N/A clear N/A N/A self N/A N/A N/A N/A N/A dict clear self N/A N/A N/A self changed N/A coerce N/A N/A cls key value N/A N/A N/A Convert plain dictionary to instance of this class. N/A N/A N/A isinstance value cls N/A N/A N/A isinstance value dict N/A N/A N/A cls value N/A N/A N/A Mutable coerce key value N/A N/A value N/A classmethod __getstate__ N/A N/A self N/A N/A N/A N/A dict self N/A __setstate__ N/A N/A self state N/A N/A N/A N/A N/A self update state N/A N/A