summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-09-10 16:54:23 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-09-10 16:54:23 -0400
commitbb62d80217e584acf3f899804bb66b19f71205e2 (patch)
tree72fb88a12bcf660be5408f5acd64518eb3381dbf /lib/sqlalchemy/orm/util.py
parente61a4438493c812990382ec5f1fc46016b319a4c (diff)
downloadsqlalchemy-bb62d80217e584acf3f899804bb66b19f71205e2.tar.gz
- New event hook, MapperEvents.after_configured().
Called after a configure() step has completed and mappers were in fact affected. Theoretically this event is called once per application, unless new mappings are constructed after existing ones have been used already. - New declarative features: - __declare_last__() method, establishes an event listener for the class method that will be called when mappers are completed with the final "configure" step. - __abstract__ flag. The class will not be mapped at all when this flag is present on the class. - New helper classes ConcreteBase, AbstractConcreteBase. Allow concrete mappings using declarative which automatically set up the "polymorphic_union" when the "configure" mapper step is invoked. - The mapper itself has semi-private methods that allow the "with_polymorphic" selectable to be assigned to the mapper after it has already been configured. [ticket:2239]
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index 3dc1f8676..d778bef3d 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -601,6 +601,9 @@ def has_identity(object):
return state.has_identity
def _is_mapped_class(cls):
+ """Return True if the given object is a mapped class,
+ :class:`.Mapper`, or :class:`.AliasedClass`."""
+
if isinstance(cls, (AliasedClass, mapperlib.Mapper)):
return True
if isinstance(cls, expression.ClauseElement):
@@ -610,6 +613,16 @@ def _is_mapped_class(cls):
return manager and _INSTRUMENTOR in manager.info
return False
+def _mapper_or_none(cls):
+ """Return the :class:`.Mapper` for the given class or None if the
+ class is not mapped."""
+
+ manager = attributes.manager_of_class(cls)
+ if manager is not None and _INSTRUMENTOR in manager.info:
+ return manager.info[_INSTRUMENTOR]
+ else:
+ return None
+
def instance_str(instance):
"""Return a string describing an instance."""