diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-01-19 23:25:43 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-01-19 23:25:43 +0000 |
commit | 81372486d9a10305f47f76c4455a5e6df02e586c (patch) | |
tree | 84cfd3a599180cb78611a358ae515bfc1078ca6e /lib/sqlalchemy | |
parent | 40f8aadd582776524d3b98da1f577c2fc95619e7 (diff) | |
download | sqlalchemy-81372486d9a10305f47f76c4455a5e6df02e586c.tar.gz |
lessons learned unpickling from an 0.5 cache
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/orm/interfaces.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/state.py | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index d8ba9ea96..0077f3e6a 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -700,7 +700,7 @@ def deserialize_path(path): from sqlalchemy.orm import class_mapper p = tuple(chain(*[(class_mapper(cls), key) for cls, key in path])) - if p[-1] is None: + if p and p[-1] is None: p = p[0:-1] return p diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 472d2c081..14c677b89 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -155,7 +155,9 @@ class InstanceState(object): "Cannot deserialize object of type %r - no mapper() has" " been configured for this class within the current Python process!" % self.class_) - + elif manager.mapper and not manager.mapper.compiled: + manager.mapper.compile() + self.committed_state = state.get('committed_state', {}) self.pending = state.get('pending', {}) self.parents = state.get('parents', {}) @@ -355,6 +357,13 @@ class InstanceState(object): self._strong_obj = None class MutableAttrInstanceState(InstanceState): + """InstanceState implementation for objects that reference 'mutable' + attributes. + + Has a more involved "cleanup" handler that checks mutable attributes + for changes upon dereference, resurrecting if needed. + + """ def __init__(self, obj, manager): self.mutable_dict = {} InstanceState.__init__(self, obj, manager) |