From 79f26dbff98a3e5625c94fbea5bfb35a2d7016cf Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 4 Aug 2012 18:11:18 -0400 Subject: - [feature] Can now provide class-bound attributes that override columns which are of any non-ORM type, not just descriptors. [ticket:2535] --- lib/sqlalchemy/orm/mapper.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 0254933c2..a1d3d6954 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -1630,18 +1630,12 @@ class Mapper(_InspectionAttr): def _is_userland_descriptor(self, obj): if isinstance(obj, (MapperProperty, - attributes.QueryableAttribute)): - return False - elif not hasattr(obj, '__get__'): + attributes.QueryableAttribute, + instrumentation.ClassManager, + expression.ColumnElement)): return False else: - obj = util.unbound_method_to_callable(obj) - if isinstance( - obj.__get__(None, obj), - attributes.QueryableAttribute - ): - return False - return True + return True def _should_exclude(self, name, assigned_name, local, column): """determine whether a particular property should be implicitly @@ -1652,8 +1646,8 @@ class Mapper(_InspectionAttr): """ - # check for descriptors, either local or from - # an inherited class + # check for class-bound attributes and/or descriptors, + # either local or from an inherited class if local: if self.class_.__dict__.get(assigned_name, None) is not None \ and self._is_userland_descriptor( -- cgit v1.2.1