From 8b313b356e5ba46c892b37fb1105c2de26e4beb2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 15 Aug 2006 02:02:47 +0000 Subject: - eesh ! the tutorial doctest was broken for quite some time. - add_property() method on mapper does a "compile all mappers" step in case the given property references a non-compiled mapper (as it did in the case of the tutorial !) --- lib/sqlalchemy/orm/mapper.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib/sqlalchemy') diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 689b3241b..ab0226a41 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -151,7 +151,17 @@ class Mapper(object): this is the 'external' version of the method which is not reentrant.""" if self.__is_compiled: return self - + + self._compile_all() + + # if we're not primary, compile us + if self.non_primary: + self._do_compile() + self._initialize_properties() + + return self + + def _compile_all(self): # compile all primary mappers for mapper in mapper_registry.values(): if not mapper.__is_compiled: @@ -162,13 +172,6 @@ class Mapper(object): if not mapper.__props_init: mapper._initialize_properties() - # if we're not primary, compile us - if self.non_primary: - self._do_compile() - self._initialize_properties() - - return self - def _check_compile(self): if self.non_primary: self._do_compile() @@ -496,6 +499,8 @@ class Mapper(object): has already been compiled, then the given MapperProperty is compiled immediately.""" self.properties[key] = prop if self.__is_compiled: + # if we're compiled, make sure all the other mappers are compiled too + self._compile_all() self._compile_property(key, prop, init=True) def _create_prop_from_column(self, column, skipmissing=False): -- cgit v1.2.1