]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The collection instrumentation sweep now skips over descriptors that raise Attribut...
authorJason Kirtland <jek@discorporate.us>
Fri, 2 May 2008 18:47:05 +0000 (18:47 +0000)
committerJason Kirtland <jek@discorporate.us>
Fri, 2 May 2008 18:47:05 +0000 (18:47 +0000)
CHANGES
lib/sqlalchemy/orm/collections.py
test/orm/collection.py

diff --git a/CHANGES b/CHANGES
index c3fa9f1fc866240995a03c5be59b53b15d440d1e..35da79f4b071626f987111c1b9c34178f93f0b2b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -46,9 +46,9 @@ CHANGES
       conflicts with a subquery or column of the same name 
       on the parent object.  [ticket:1019]
 
-    - Removed a class-member inspection step from attribute
-      instrumentation that could be problematic when integrating
-      with other frameworks.
+    - Adjusted class-member inspection durint attribute and
+      collection instrumentation that could be problematic when
+      integrating with other frameworks.
 
 - declarative extension
     - Joined table inheritance mappers use a slightly relaxed
index 1c07fb809420de057dc1d0250d6ddc7d7f56a32e..ae4cb65cde93bbb78fbd40823c90c31f7c3ec786 100644 (file)
@@ -750,7 +750,7 @@ def _instrument_class(cls):
     methods = roles.pop('methods', {})
 
     for name in dir(cls):
-        method = getattr(cls, name)
+        method = getattr(cls, name, None)
         if not callable(method):
             continue
 
index 2abec607a68fd7e50e69347c55538b99e328313a..17c15876dd8f5a8e06f38fd061ecd9b43179b718 100644 (file)
@@ -1724,5 +1724,23 @@ class CustomCollectionsTest(ORMTest):
         o = list(p2.children)
         assert len(o) == 3
 
+
+class InstrumentationTest(TestBase):
+
+    def test_uncooperative_descriptor_in_sweep(self):
+        class DoNotTouch(object):
+            def __get__(self, obj, owner):
+                raise AttributeError
+
+        class Touchy(list):
+            no_touch = DoNotTouch()
+
+        assert 'no_touch' in Touchy.__dict__
+        assert not hasattr(Touchy, 'no_touch')
+        assert 'no_touch' in dir(Touchy)
+
+        instrumented = collections._instrument_class(Touchy)
+        assert True
+
 if __name__ == "__main__":
     testenv.main()