diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-06 21:37:25 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-12-06 21:37:25 +0000 |
| commit | 21d4e2a96eb8f505e8d2c942204917477c4323d3 (patch) | |
| tree | 015fa058d48dc918df7f4d8776818a383b697f4c /lib/sqlalchemy | |
| parent | 309c332f1f69a8554524c29add98721a06da636e (diff) | |
| download | sqlalchemy-21d4e2a96eb8f505e8d2c942204917477c4323d3.tar.gz | |
moved _impl_dict to an external weakref so that TypeEngine objects can be pickled
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/types.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 08f2c9843..eddb5d306 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -12,19 +12,20 @@ __all__ = [ 'TypeEngine', 'TypeDecorator', 'NullTypeEngine', ] from sqlalchemy import util, exceptions -import inspect +import inspect, weakref try: import cPickle as pickle except: import pickle +_impl_cache = weakref.WeakKeyDictionary() + class AbstractType(object): def _get_impl_dict(self): try: - return self._impl_dict - except AttributeError: - self._impl_dict = {} - return self._impl_dict + return _impl_cache[self] + except KeyError: + return _impl_cache.setdefault(self, {}) impl_dict = property(_get_impl_dict) def copy_value(self, value): |
