summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-10-25 20:28:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-10-25 20:28:03 -0400
commit7f043a9666eecdecc54fe779ffdd50a7d5bb0086 (patch)
tree945a98439e89265422632d20289babbe3079f7b1 /lib/sqlalchemy/orm/attributes.py
parent519c705317e801d714bd05a28f8b2786695d81cc (diff)
downloadsqlalchemy-7f043a9666eecdecc54fe779ffdd50a7d5bb0086.tar.gz
- some naming changes on PropComparator, Comparator:
1. all Comparators now have "parent" which is always the parent mapper or AliasedClass instance 2. only RelationshipProperty.Comparator has "mapper" now, which is the target mapper 3. The names "parententity" and "parentmapper" are underscored also improved the message with the "neither comparator nor instruentedattribute...." to include the classname + attribute name
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r--lib/sqlalchemy/orm/attributes.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 86da9a61d..7effd8e58 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -131,7 +131,7 @@ class QueryableAttribute(interfaces._MappedAttribute,
self.key = key
self.impl = impl
self.comparator = comparator
- self.parententity = parententity
+ self._parententity = parententity
self._of_type = of_type
manager = manager_of_class(class_)
@@ -159,6 +159,10 @@ class QueryableAttribute(interfaces._MappedAttribute,
return self
@property
+ def parent(self):
+ return self._parententity
+
+ @property
def expression(self):
return self.comparator.__clause_element__()
@@ -171,7 +175,7 @@ class QueryableAttribute(interfaces._MappedAttribute,
self.key,
self.impl,
self.comparator.of_type(cls),
- self.parententity,
+ self._parententity,
of_type=cls)
def label(self, name):
@@ -191,9 +195,11 @@ class QueryableAttribute(interfaces._MappedAttribute,
return getattr(self.comparator, key)
except AttributeError:
raise AttributeError(
- 'Neither %r object nor %r object has an attribute %r' % (
+ 'Neither %r object nor %r object associated with %s '
+ 'has an attribute %r' % (
type(self).__name__,
type(self.comparator).__name__,
+ self,
key)
)
@@ -281,7 +287,7 @@ def create_proxied_attribute(descriptor):
return self.descriptor.__get__(instance, owner)
def __str__(self):
- return self.key
+ return "%s.%s" % (self.class_.__name__, self.key)
def __getattr__(self, attribute):
"""Delegate __getattr__ to the original descriptor and/or
@@ -294,12 +300,15 @@ def create_proxied_attribute(descriptor):
return getattr(self.comparator, attribute)
except AttributeError:
raise AttributeError(
- 'Neither %r object nor %r object has an attribute %r' % (
+ 'Neither %r object nor %r object associated with %s '
+ 'has an attribute %r' % (
type(descriptor).__name__,
type(self.comparator).__name__,
+ self,
attribute)
)
+
Proxy.__name__ = type(descriptor).__name__ + 'Proxy'
util.monkeypatch_proxied_specials(Proxy, type(descriptor),