]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
simplify this
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 30 Nov 2013 15:26:11 +0000 (10:26 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 30 Nov 2013 15:26:11 +0000 (10:26 -0500)
examples/vertical/dictlike.py

index 1a3631354b9bbb366c68ff5dba47e40040dc2648..08989d8c2aa9be1dc58415dae350c6cf59bffd74 100644 (file)
@@ -31,22 +31,14 @@ can be used with many common vertical schemas as-is or with minor adaptations.
 
 """
 from __future__ import unicode_literals
-from sqlalchemy.util.compat import with_metaclass
-from collections import MutableMapping
-from abc import ABCMeta
-from sqlalchemy.ext.declarative import DeclarativeMeta
 
-
-class ProxiedDictMixin(MutableMapping):
+class ProxiedDictMixin(object):
     """Adds obj[key] access to a mapped class.
 
     This class basically proxies dictionary access to an attribute
     called ``_proxied``.  The class which inherits this class
     should have an attribute called ``_proxied`` which points to a dictionary.
 
-    The use of this class is optional, as it requires some
-    elaborate metaclass arithmetic in order to use it with declarative.
-
     """
 
     def __len__(self):
@@ -67,16 +59,6 @@ class ProxiedDictMixin(MutableMapping):
     def __delitem__(self, key):
         del self._proxied[key]
 
-    @classmethod
-    def _base_class(cls, base):
-        """Perform the requisite metaclass trickery in order
-        to get DeclarativeMeta and ABCMeta to play nicely together,
-        while also remaining Python 2/3 agnostic.
-
-        """
-        return with_metaclass(
-                        type(str("MutableBase"), (ABCMeta, DeclarativeMeta), {}),
-                        base, cls)
 
 if __name__ == '__main__':
     from sqlalchemy import (Column, Integer, Unicode,
@@ -97,7 +79,7 @@ if __name__ == '__main__':
         key = Column(Unicode(64), primary_key=True)
         value = Column(UnicodeText)
 
-    class Animal(ProxiedDictMixin._base_class(Base)):
+    class Animal(ProxiedDictMixin, Base):
         """an Animal"""
 
         __tablename__ = 'animal'