Commits

Mike Bayer committed f21f05b

- 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]

  • Participants
  • Parent commits aea7b1c

Comments (0)

Files changed (2)

   - 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

File lib/sqlalchemy/ext/mutable.py

     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."
             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
 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):