summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/interfaces.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-01-22 03:55:48 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-01-22 03:55:48 +0000
commit3954df86cb950aeb65444116c3e20f0a51647c10 (patch)
treefed1ba8c150feede8f429833c1aa92fc916ebf7b /lib/sqlalchemy/orm/interfaces.py
parenta7459fe1abaec1c4d6aca443e7b7e5f1d1e6db21 (diff)
downloadsqlalchemy-3954df86cb950aeb65444116c3e20f0a51647c10.tar.gz
- Adjusted the attribute instrumentation change from 0.5.1 to
fully establish instrumentation for subclasses where the mapper was created after the superclass had already been fully instrumented. [ticket:1292]
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
-rw-r--r--lib/sqlalchemy/orm/interfaces.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py
index 3e0fb94a4..6c3c3b1ba 100644
--- a/lib/sqlalchemy/orm/interfaces.py
+++ b/lib/sqlalchemy/orm/interfaces.py
@@ -395,23 +395,35 @@ class MapperProperty(object):
def instrument_class(self, mapper):
raise NotImplementedError()
+ _compile_started = False
+ _compile_finished = False
+
def init(self):
- """Called after all mappers are compiled to assemble
- relationships between mappers, establish instrumented class
- attributes.
+ """Called after all mappers are created to assemble
+ relationships between mappers and perform other post-mapper-creation
+ initialization steps.
+
"""
-
- self._compiled = True
+ self._compile_started = True
self.do_init()
-
+ self._compile_finished = True
+
def do_init(self):
- """Perform subclass-specific initialization steps.
+ """Perform subclass-specific initialization post-mapper-creation steps.
This is a *template* method called by the
- ``MapperProperty`` object's init() method."""
-
+ ``MapperProperty`` object's init() method.
+
+ """
pass
-
+
+ def post_instrument_class(self, mapper):
+ """Perform instrumentation adjustments that need to occur
+ after init() has completed.
+
+ """
+ pass
+
def register_dependencies(self, *args, **kwargs):
"""Called by the ``Mapper`` in response to the UnitOfWork
calling the ``Mapper``'s register_dependencies operation.
@@ -573,9 +585,11 @@ class StrategizedProperty(MapperProperty):
def do_init(self):
self.__all_strategies = {}
self.strategy = self.__init_strategy(self.strategy_class)
- if self.is_primary():
- self.strategy.init_class_attribute()
+ def post_instrument_class(self, mapper):
+ if self.is_primary():
+ self.strategy.init_class_attribute(mapper)
+
def build_path(entity, key, prev=None):
if prev:
return prev + (entity, key)
@@ -810,7 +824,7 @@ class LoaderStrategy(object):
def init(self):
raise NotImplementedError("LoaderStrategy")
- def init_class_attribute(self):
+ def init_class_attribute(self, mapper):
pass
def setup_query(self, context, entity, path, adapter, **kwargs):