diff --git a/docs/changelog.rst b/docs/changelog.rst index 02887fd61..7d5b1335d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,10 @@ Changelog ========= +Changes in 0.6.X +================ +- Fixed recursive save with FileField + Changes in 0.6.10 ================= - Fixed basedict / baselist to return super(..) diff --git a/mongoengine/fields.py b/mongoengine/fields.py index c72c6cb49..bba8f0b55 100644 --- a/mongoengine/fields.py +++ b/mongoengine/fields.py @@ -889,6 +889,13 @@ def __getstate__(self): self_dict['_fs'] = None return self_dict + def __repr__(self): + return '<%s: %s>' % (self.__class__.__name__, self.grid_id) + + def __cmp__(self, other): + return cmp((self.grid_id, self.collection_name, self.db_alias), + (other.grid_id, other.collection_name, other.db_alias)) + @property def fs(self): if not self._fs: diff --git a/tests/test_document.py b/tests/test_document.py index ae2257da6..b50d71615 100644 --- a/tests/test_document.py +++ b/tests/test_document.py @@ -1335,7 +1335,7 @@ def test_save_max_recursion_not_hit_with_file_field(self): class Foo(Document): name = StringField() - file = FileField() + picture = FileField() bar = ReferenceField('self') Foo.drop_collection() @@ -1344,7 +1344,7 @@ class Foo(Document): a.save() a.bar = a - a.file = open(TEST_IMAGE_PATH, 'rb') + a.picture = open(TEST_IMAGE_PATH, 'rb') a.save() # Confirm can save and it resets the changed fields without hitting @@ -1353,7 +1353,7 @@ class Foo(Document): b.name='world' b.save() - self.assertEquals(b.file, b.bar.file, b.bar.bar.file) + self.assertEquals(b.picture, b.bar.picture, b.bar.bar.picture) def test_save_cascades(self):