diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-04-26 21:57:18 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-04-26 21:57:18 +0000 |
| commit | 85f754751412fd48f915e7c3062689401a3723b8 (patch) | |
| tree | 3b3d1c95d54a6b27a5b5ac0027be714950b4696e /lib/sqlalchemy | |
| parent | 1ec5704d142aded7505be4f7ef6ab02fc9410092 (diff) | |
| download | sqlalchemy-85f754751412fd48f915e7c3062689401a3723b8.tar.gz | |
- Allowed pickling of PropertyOption objects constructed with
instrumented descriptors; previously, pickle errors would occur
when pickling an object which was loaded with a descriptor-based
option, such as query.options(eagerload(MyClass.foo)).
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/interfaces.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 3b7507def..d36f51194 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -682,6 +682,27 @@ class PropertyOption(MapperOption): else: return None + def __getstate__(self): + d = self.__dict__.copy() + d['key'] = ret = [] + for token in util.to_list(self.key): + if isinstance(token, PropComparator): + ret.append((token.mapper.class_, token.key)) + else: + ret.append(token) + return d + + def __setstate__(self, state): + ret = [] + for key in state['key']: + if isinstance(key, tuple): + cls, propkey = key + ret.append(getattr(cls, propkey)) + else: + ret.append(key) + state['key'] = tuple(ret) + self.__dict__ = state + def __get_paths(self, query, raiseerr): path = None entity = None |
