summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2008-03-22 22:30:08 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2008-03-22 22:30:08 +0000
commit8ef1bded27632d818db2b24f733579d2f436e6bc (patch)
tree5bdcb1f85da76f886f7c232e07f1f8a45e87590d /lib/sqlalchemy
parent82198afee9a94925d6b30eb0e612fd3a93170338 (diff)
downloadsqlalchemy-8ef1bded27632d818db2b24f733579d2f436e6bc.tar.gz
added nicer error message to dependent class not found
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/ext/declarative.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index 784236662..62691a906 100644
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -161,7 +161,7 @@ from sqlalchemy.schema import Table, SchemaItem, Column, MetaData
from sqlalchemy.orm import synonym as _orm_synonym, mapper, comparable_property
from sqlalchemy.orm.interfaces import MapperProperty
from sqlalchemy.orm.properties import PropertyLoader, ColumnProperty
-from sqlalchemy import util
+from sqlalchemy import util, exceptions
__all__ = ['declarative_base', 'synonym_for', 'comparable_using',
'declared_synonym']
@@ -237,7 +237,10 @@ def _deferred_relation(cls, prop):
if isinstance(prop, PropertyLoader) and isinstance(prop.argument, basestring):
arg = prop.argument
def return_cls():
- return cls._decl_class_registry[arg]
+ try:
+ return cls._decl_class_registry[arg]
+ except KeyError:
+ raise exceptions.InvalidRequestError("When compiling mapper %s, could not locate a declarative class named %r. Consider adding this property to the %r class after both dependent classes have been defined." % (prop.parent, arg, prop.parent.class_))
prop.argument = return_cls
return prop