diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-02-19 15:48:37 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-02-19 15:48:37 +0000 |
| commit | 734e02c4f152cee6152c9f5bcbbccf3e33ea7e65 (patch) | |
| tree | fe03cc8798e658732bd2f3684823793ede1ed1cf /lib/sqlalchemy | |
| parent | 40b20c680a5fe8ef85b9b99b23769f4dc59f1504 (diff) | |
| download | sqlalchemy-734e02c4f152cee6152c9f5bcbbccf3e33ea7e65.tar.gz | |
- Declarative locates the "inherits" class using a search
through __bases__, to skip over mixins that are local
to subclasses.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/ext/declarative.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index f1b2e65fb..79677c084 100644 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -400,6 +400,7 @@ from sqlalchemy.schema import Table, Column, MetaData from sqlalchemy.orm import synonym as _orm_synonym, mapper, comparable_property, class_mapper from sqlalchemy.orm.interfaces import MapperProperty from sqlalchemy.orm.properties import PropertyLoader, ColumnProperty +from sqlalchemy.orm.util import _is_mapped_class from sqlalchemy import util, exceptions from sqlalchemy.sql import util as sql_util @@ -483,10 +484,10 @@ def _as_declarative(cls, classname, dict_): mapper_args = getattr(cls, '__mapper_args__', {}) if 'inherits' not in mapper_args: - inherits = cls.__mro__[1] - inherits = cls._decl_class_registry.get(inherits.__name__, None) - if inherits: - mapper_args['inherits'] = inherits + for c in cls.__bases__: + if _is_mapped_class(c): + mapper_args['inherits'] = cls._decl_class_registry.get(c.__name__, None) + break if hasattr(cls, '__mapper_cls__'): mapper_cls = util.unbound_method_to_callable(cls.__mapper_cls__) |
