From 9e67941badd0ddd680b2fc582499f7c660b2ea4b Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Tue, 14 Aug 2012 10:34:17 +0100 Subject: [PATCH] Use weakref proxies in base lists / dicts (MongoEngine/mongoengine#74) --- docs/changelog.rst | 1 + mongoengine/base.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9deb6932..64047c38 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,7 @@ Changelog Changes in 0.7.X ================= +- Use weakref proxies in base lists / dicts (MongoEngine/mongoengine#74) - Improved queryset filtering (hmarr/mongoengine#554) - Fixed Dynamic Documents and Embedded Documents (hmarr/mongoengine#561) - Fixed abstract classes and shard keys (MongoEngine/mongoengine#64) diff --git a/mongoengine/base.py b/mongoengine/base.py index b2348ac8..6c86506d 100644 --- a/mongoengine/base.py +++ b/mongoengine/base.py @@ -1,6 +1,7 @@ import operator import sys import warnings +import weakref from collections import defaultdict from functools import partial @@ -1265,7 +1266,7 @@ class BaseList(list): _name = None def __init__(self, list_items, instance, name): - self._instance = instance + self._instance = weakref.proxy(instance) self._name = name return super(BaseList, self).__init__(list_items) @@ -1327,7 +1328,7 @@ class BaseDict(dict): _name = None def __init__(self, dict_items, instance, name): - self._instance = instance + self._instance = weakref.proxy(instance) self._name = name return super(BaseDict, self).__init__(dict_items)