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]

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

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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.