]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Backported attribute sweep removal (instrumentation) and r4493 from 0.5
authorJason Kirtland <jek@discorporate.us>
Fri, 2 May 2008 17:46:44 +0000 (17:46 +0000)
committerJason Kirtland <jek@discorporate.us>
Fri, 2 May 2008 17:46:44 +0000 (17:46 +0000)
CHANGES
lib/sqlalchemy/ext/associationproxy.py
lib/sqlalchemy/orm/attributes.py

diff --git a/CHANGES b/CHANGES
index 5d273845afd9a47bd7ad2ddaa5e27543eb210755..4efb2a97506e1270ea170f3f16e3c17b132427c2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -45,7 +45,11 @@ CHANGES
       the instance is part of the eager join, to prevent
       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.
+
 - declarative extension
     - Joined table inheritance mappers use a slightly relaxed
       function to create the "inherit condition" to the parent
@@ -85,7 +89,6 @@ CHANGES
       This should obviate the need of adding a myriad of ODBC
       options in the future.
 
-
 - firebird
     - Handle the "SUBSTRING(:string FROM :start FOR :length)"
       builtin.
index 45c91eab2ee32b34f140bb71f939a0f10908d4bd..bcbfb478004a2f464a0774e76709581c6d3a33f6 100644 (file)
@@ -143,9 +143,10 @@ class AssociationProxy(object):
         return lazy_collection
 
     def __get__(self, obj, class_):
+        if self.owning_class is None:
+            self.owning_class = class_ and class_ or type(obj)
         if obj is None:
-            self.owning_class = class_
-            return
+            return None
         elif self.scalar is None:
             self.scalar = self._target_is_scalar()
             if self.scalar:
@@ -167,6 +168,8 @@ class AssociationProxy(object):
             return proxy
 
     def __set__(self, obj, values):
+        if self.owning_class is None:
+            self.owning_class = type(obj)
         if self.scalar is None:
             self.scalar = self._target_is_scalar()
             if self.scalar:
@@ -186,6 +189,8 @@ class AssociationProxy(object):
                 self._set(proxy, values)
 
     def __delete__(self, obj):
+        if self.owning_class is None:
+            self.owning_class = type(obj)
         delattr(obj, self.key)
 
     def _initialize_scalar_accessors(self):
index f57298d7cd1b6b381bb0853dfb27afcb3691d6e6..fb0621a70f5320b861f17cd49e59e7867cba1c6b 100644 (file)
@@ -1197,12 +1197,6 @@ def _init_class_state(class_):
         class_._class_state = ClassState()
 
 def register_class(class_, extra_init=None, on_exception=None, deferred_scalar_loader=None):
-    # do a sweep first, this also helps some attribute extensions
-    # (like associationproxy) become aware of themselves at the
-    # class level
-    for key in dir(class_):
-        getattr(class_, key, None)
-
     _init_class_state(class_)
     class_._class_state.deferred_scalar_loader=deferred_scalar_loader