From: Jason Kirtland Date: Fri, 2 May 2008 17:46:44 +0000 (+0000) Subject: - Backported attribute sweep removal (instrumentation) and r4493 from 0.5 X-Git-Tag: rel_0_5beta1~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e3021baf431cb9a77335132af7a6dad1f7fa298;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Backported attribute sweep removal (instrumentation) and r4493 from 0.5 --- diff --git a/CHANGES b/CHANGES index 5d273845af..4efb2a9750 100644 --- 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. diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index 45c91eab2e..bcbfb47800 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -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): diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index f57298d7cd..fb0621a70f 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -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