summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-07-08 10:16:13 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-07-08 10:16:13 -0400
commitd559f9fc94a9635984470634a7b6714e168361a0 (patch)
tree85b952a8c3e8b9ea6294be398c26a118f301db37 /lib/sqlalchemy/orm/util.py
parent3f6e16c3de78e12c710980bc38f602bfdf53dc5d (diff)
downloadsqlalchemy-d559f9fc94a9635984470634a7b6714e168361a0.tar.gz
- Improved the check for an "unmapped class",
including the case where the superclass is mapped but the subclass is not. Any attempts to access cls._sa_class_manager.mapper now raise UnmappedClassError(). [ticket:1142]
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 651b0256b..a2e3c5433 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -570,9 +570,9 @@ def object_mapper(instance):
"""
try:
state = attributes.instance_state(instance)
- if not state.manager.mapper:
- raise exc.UnmappedInstanceError(instance)
return state.manager.mapper
+ except exc.UnmappedClassError:
+ raise exc.UnmappedInstanceError(instance)
except exc.NO_STATE:
raise exc.UnmappedInstanceError(instance)
@@ -582,14 +582,11 @@ def class_mapper(class_, compile=True):
Raises UnmappedClassError if no mapping is configured.
"""
+
try:
class_manager = attributes.manager_of_class(class_)
mapper = class_manager.mapper
- # HACK until [ticket:1142] is complete
- if mapper is None:
- raise AttributeError
-
except exc.NO_STATE:
raise exc.UnmappedClassError(class_)