diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-11-15 07:44:14 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-11-15 07:44:14 +0000 |
commit | da720e3d644b516d86de12bccf7c4c8c1be77390 (patch) | |
tree | 1ed5703b4c60b4db0ae875a0108de7b09b56f1b1 /lib/sqlalchemy/mapper.py | |
parent | 77a994da498b2cfac894315bc5aef15f715621c5 (diff) | |
download | sqlalchemy-da720e3d644b516d86de12bccf7c4c8c1be77390.tar.gz |
enhancements to lazyloader. now you can pickle objects with lazyload.
Diffstat (limited to 'lib/sqlalchemy/mapper.py')
-rw-r--r-- | lib/sqlalchemy/mapper.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sqlalchemy/mapper.py b/lib/sqlalchemy/mapper.py index 5e677705e..bdbbb6a69 100644 --- a/lib/sqlalchemy/mapper.py +++ b/lib/sqlalchemy/mapper.py @@ -1039,11 +1039,14 @@ class LazyLoader(PropertyLoader): def execute(self, instance, row, identitykey, imap, isnew): if isnew: - # when new rows are processed, we re-set a lazyloader on the instance. this is because the constructors - # of an object might try to access its lazy-properties, which will result in nothing being returned - # since we havent mapped anything into the instance yet. - lazyload = self.setup_loader(instance) - objectstore.uow().register_callable(instance, self.key, lazyload, uselist=self.uselist, deleteremoved = self.private, live=self.live) + # when new rows are processed, we remove the managed attribute list from our object property, + # which has the effect of the class-level lazyloader being reset. this is because the constructors + # of an object, called upon object creation when the instance is created from a result set, + # might try to access its lazy-properties, which will result in nothing being returned. + # then the instance gets its state loaded from the row, but the lazyload was already triggered; + # thus this step, occuring only when the instance was just loaded from a row, + # insures that it will be triggered even if the constructor already triggered it. + objectstore.uow().attributes.reset_history(instance, self.key) def create_lazy_clause(table, primaryjoin, secondaryjoin, foreignkey): binds = {} |