diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-11 19:55:34 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-11 19:55:34 -0500 |
commit | 4a79bc578c67297c707a00d8fafaba533e2833d9 (patch) | |
tree | 808a412724a8137a95472ba974def1073ea1a301 /lib/sqlalchemy/ext/declarative/api.py | |
parent | 0050a8d3db04767b97e48f3aa71381b786481231 (diff) | |
download | sqlalchemy-4a79bc578c67297c707a00d8fafaba533e2833d9.tar.gz |
- Fixed bug where :class:`.AbstractConcreteBase` would fail to be
fully usable within declarative relationship configuration, as its
string classname would not be available in the registry of classnames
at mapper configuration time. The class now explicitly adds itself
to the class regsitry, and additionally both :class:`.AbstractConcreteBase`
as well as :class:`.ConcreteBase` set themselves up *before* mappers
are configured within the :func:`.configure_mappers` setup, using
the new :meth:`.MapperEvents.before_configured` event. [ticket:2950]
- Added new :meth:`.MapperEvents.before_configured` event which allows
an event at the start of :func:`.configure_mappers`, as well
as ``__declare_first__()`` hook within declarative to complement
``__declare_last__()``.
- modified how after_configured is invoked; we just make a dispatch()
not actually connected to any mapper. this makes it easier
to also invoke before_configured correctly.
- improved the ComparableEntity fixture to handle collections that are sets.
Diffstat (limited to 'lib/sqlalchemy/ext/declarative/api.py')
-rw-r--r-- | lib/sqlalchemy/ext/declarative/api.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sqlalchemy/ext/declarative/api.py b/lib/sqlalchemy/ext/declarative/api.py index 2418c6e50..84b97f629 100644 --- a/lib/sqlalchemy/ext/declarative/api.py +++ b/lib/sqlalchemy/ext/declarative/api.py @@ -20,7 +20,7 @@ from .base import _as_declarative, \ _declarative_constructor,\ _DeferredMapperConfig, _add_attribute from .clsregistry import _class_resolver - +from . import clsregistry def instrument_declarative(cls, registry, metadata): """Given a class, configure the class declaratively, @@ -325,7 +325,7 @@ class ConcreteBase(object): ), 'type', 'pjoin') @classmethod - def __declare_last__(cls): + def __declare_first__(cls): m = cls.__mapper__ if m.with_polymorphic: return @@ -370,10 +370,11 @@ class AbstractConcreteBase(ConcreteBase): __abstract__ = True @classmethod - def __declare_last__(cls): + def __declare_first__(cls): if hasattr(cls, '__mapper__'): return + clsregistry.add_class(cls.__name__, cls) # can't rely on 'self_and_descendants' here # since technically an immediate subclass # might not be mapped, but a subclass |