From 21d4e2a96eb8f505e8d2c942204917477c4323d3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 6 Dec 2006 21:37:25 +0000 Subject: [PATCH] moved _impl_dict to an external weakref so that TypeEngine objects can be pickled --- lib/sqlalchemy/types.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 08f2c98436..eddb5d306f 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): -- 2.47.2