From 425b7388cc7808751bd73a647c05fc669ea6dbbf Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 28 Apr 2011 12:10:24 -0400 Subject: [PATCH] - Removed the usage of the "collections.MutableMapping" abc from the ext.mutable docs as it was being used incorrectly and makes the example more difficult to understand in any case. [ticket:2152] --- CHANGES | 6 ++++++ lib/sqlalchemy/ext/mutable.py | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index b6927eda1f..622451ca85 100644 --- a/CHANGES +++ b/CHANGES @@ -61,6 +61,12 @@ CHANGES - Fixed the psycopg2_version parsing in the psycopg2 dialect. +- documentation + - Removed the usage of the "collections.MutableMapping" + abc from the ext.mutable docs as it was being used + incorrectly and makes the example more difficult + to understand in any case. [ticket:2152] + - examples - removed the ancient "polymorphic association" examples and replaced with an updated set of diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 9be559d04f..d14cfe3c0f 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -56,7 +56,7 @@ the :class:`.Mutable` mixin:: import collections from sqlalchemy.ext.mutable import Mutable - class MutationDict(Mutable, collections.MutableMapping, dict): + class MutationDict(Mutable, dict): @classmethod def coerce(cls, key, value): "Convert plain dictionaries to MutationDict." @@ -83,11 +83,11 @@ the :class:`.Mutable` mixin:: self.changed() The above dictionary class takes the approach of subclassing the Python -built-ins ``collections.MutableMapping`` and ``dict`` to produce a dict +built-in ``dict`` to produce a dict subclass which routes all mutation events through ``__setitem__``. There are many variants on this approach, such as subclassing ``UserDict.UserDict``, -etc. The part that's important to this example is that the -:meth:`.Mutable.changed` method is called whenever an in-place change to the +the newer ``collections.MutableMapping``, etc. 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 @@ -193,7 +193,7 @@ stream:: With our dictionary example, we need to return the contents of the dict itself (and also restore them on __setstate__):: - class MutationDict(Mutable, collections.MutableMapping, dict): + class MutationDict(Mutable, dict): # .... def __getstate__(self): -- 2.39.5