diff options
author | Chris Withers <chris@simplistix.co.uk> | 2010-04-13 11:29:39 +0100 |
---|---|---|
committer | Chris Withers <chris@simplistix.co.uk> | 2010-04-13 11:29:39 +0100 |
commit | aaa0ba0525da3186e3ad88194c66f667685c5a67 (patch) | |
tree | 2cabd9b05262ca616a8220173c382b78305fed37 /lib/sqlalchemy/ext/declarative.py | |
parent | 1e191b601cc1230505ea5ade34f411c72f0f5a66 (diff) | |
download | sqlalchemy-aaa0ba0525da3186e3ad88194c66f667685c5a67.tar.gz |
helper method for spotting inherited tables
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-x | lib/sqlalchemy/ext/declarative.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 0c7aa68db..8ed83d6cd 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -528,7 +528,16 @@ def instrument_declarative(cls, registry, metadata): cls._decl_class_registry = registry cls.metadata = metadata _as_declarative(cls, cls.__name__, cls.__dict__) - + +def has_inherited_table(cls): + """Given a class, return True if any of the classes it inherits from has a mapped + table, otherwise return False. + """ + for class_ in cls.__mro__: + if getattr(class_,'__table__',None) is not None: + return True + return False + def _as_declarative(cls, classname, dict_): # dict_ will be a dictproxy, which we can't write to, and we need to! |