diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-14 14:24:51 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-07-14 14:24:51 -0400 |
commit | 6dad6332cd0b777e4d876f51fada4fdf31299c53 (patch) | |
tree | 96233c7de4eeff08afe15ef2661c771f40235111 /lib/sqlalchemy/ext/declarative.py | |
parent | 58adf7b729348f415100c5bb9671de7e303b57a8 (diff) | |
download | sqlalchemy-6dad6332cd0b777e4d876f51fada4fdf31299c53.tar.gz |
- [feature] The registry of classes
in declarative_base() is now a
WeakValueDictionary. So subclasses of
"Base" that are dereferenced will be
garbage collected, *if they are not
referred to by any other mappers/superclass
mappers*. [ticket:2526]
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-x | lib/sqlalchemy/ext/declarative.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 23346730f..651a94970 100755 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -1036,7 +1036,7 @@ from sqlalchemy import util, exc from sqlalchemy.sql import util as sql_util, expression from sqlalchemy import event from sqlalchemy.orm.util import polymorphic_union, _mapper_or_none - +import weakref __all__ = 'declarative_base', 'synonym_for', \ 'comparable_using', 'instrument_declarative' @@ -1718,7 +1718,7 @@ def declarative_base(bind=None, metadata=None, mapper=None, cls=object, lcl_metadata.bind = bind if class_registry is None: - class_registry = {} + class_registry = weakref.WeakValueDictionary() bases = not isinstance(cls, tuple) and (cls,) or cls class_dict = dict(_decl_class_registry=class_registry, |