]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
[ticket:254]
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Jul 2006 16:25:40 +0000 (16:25 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Jul 2006 16:25:40 +0000 (16:25 +0000)
lib/sqlalchemy/attributes.py
test/base/attributes.py

index 5e2226e9d5e9877d31b04615940ffadb10d054ff..724f1c807ceeab7915f9e48bdac104f087ff4c88 100644 (file)
@@ -573,7 +573,7 @@ class AttributeManager(object):
         if not isinstance(class_, type):
             raise repr(class_) + " is not a type"
         for key in dir(class_):
-            value = getattr(class_, key)
+            value = getattr(class_, key, None)
             if isinstance(value, InstrumentedAttribute):
                 yield value
                 
index 19eedd0f693d3d863c414a3c6e9fb8109101098a..5f555a7e60a79846ae47f4ea9f24e66ed93ac21f 100644 (file)
@@ -251,6 +251,21 @@ class AttributesTest(PersistTest):
         
         b2.element = None
         assert not manager.get_history(b2, 'element').hasparent(f2)
+
+    def testdescriptorattributes(self):
+        """changeset: 1633 broke ability to use ORM to map classes with unusual
+        descriptor attributes (for example, classes that inherit from ones
+        implementing zope.interface.Interface).
+        This is a simple regression test to prevent that defect.
+        """
+        class des(object):
+            def __get__(self, instance, owner): raise AttributeError('fake attribute')
+
+        class Foo(object):
+            A = des()
+
+        manager = attributes.AttributeManager()
+        manager.reset_class_managed(Foo)
         
 if __name__ == "__main__":
     unittest.main()