diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-15 18:01:00 +0200 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-05-15 18:01:00 +0200 |
commit | e04dc932be2d14d98f2c259b052f967c545eae0d (patch) | |
tree | 629f779177bf7efc99b91fb4b8046e16ca9bab67 /lib/sqlalchemy/ext/declarative.py | |
parent | 5e07ebf4ea200483eb2acd4eb35176a2d29e7a24 (diff) | |
download | sqlalchemy-e04dc932be2d14d98f2c259b052f967c545eae0d.tar.gz |
clean this up some more. __mapper__ isn't even set up.
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-x | lib/sqlalchemy/ext/declarative.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 640e5430b..58e8e6de6 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -1026,13 +1026,11 @@ __all__ = 'declarative_base', 'synonym_for', \ 'comparable_using', 'instrument_declarative' def declared_mapping_info(cls): - if '__mapper__' in cls.__dict__: - return cls.__mapper__ + # deferred mapping + if cls in _MapperThingy.thingies: + return _MapperThingy.thingies[cls] + # regular mapping elif _is_mapped_class(cls): - # TODO: make sure there's coverage here, need - # a declared to inherit from a classical mapping. - # if this is not possible then this codepath - # goes away return class_mapper(cls, compile=False) else: return None @@ -1339,14 +1337,13 @@ def _as_declarative(cls, classname, dict_): our_stuff[k] = p.columns + [col] - cls.__mapper__ = _MapperThingy( - mapper_cls, - cls, table, our_stuff, mapper_args) + mt = _MapperThingy(mapper_cls, + cls, table, our_stuff, mapper_args) if not hasattr(cls, '__prepare__'): - cls.__mapper__.map() + mt.map() class _MapperThingy(object): - thingies = set() + thingies = util.OrderedDict() def __init__(self, mapper_cls, cls, table, properties, mapper_args): self.mapper_cls = mapper_cls @@ -1357,10 +1354,10 @@ class _MapperThingy(object): self._columntoproperty = set() if table is not None: self._columntoproperty.update(table.c) - self.thingies.add(self) + self.thingies[cls] = self def map(self): - self.thingies.discard(self) + self.thingies.pop(self.cls, None) self.cls.__mapper__ = self.mapper_cls( self.cls, self.local_table, @@ -1369,7 +1366,7 @@ class _MapperThingy(object): ) def prepare_deferred_mapping(base, *arg, **kw): - to_map = set([m for m in _MapperThingy.thingies + to_map = set([m for m in _MapperThingy.thingies.values() if issubclass(m.cls, base)]) for thingy in to_map: base.__prepare__(thingy, *arg, **kw) |