Fixes cascading saves with filefields

fixes #24 #25
This commit is contained in:
Ross Lawley 2012-06-18 16:45:14 +01:00
parent e4bc92235d
commit 89a6eee6af
3 changed files with 14 additions and 3 deletions

View File

@ -2,6 +2,10 @@
Changelog Changelog
========= =========
Changes in 0.6.X
================
- Fixed recursive save with FileField
Changes in 0.6.10 Changes in 0.6.10
================= =================
- Fixed basedict / baselist to return super(..) - Fixed basedict / baselist to return super(..)

View File

@ -889,6 +889,13 @@ class GridFSProxy(object):
self_dict['_fs'] = None self_dict['_fs'] = None
return self_dict 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 @property
def fs(self): def fs(self):
if not self._fs: if not self._fs:

View File

@ -1335,7 +1335,7 @@ class DocumentTest(unittest.TestCase):
class Foo(Document): class Foo(Document):
name = StringField() name = StringField()
file = FileField() picture = FileField()
bar = ReferenceField('self') bar = ReferenceField('self')
Foo.drop_collection() Foo.drop_collection()
@ -1344,7 +1344,7 @@ class DocumentTest(unittest.TestCase):
a.save() a.save()
a.bar = a a.bar = a
a.file = open(TEST_IMAGE_PATH, 'rb') a.picture = open(TEST_IMAGE_PATH, 'rb')
a.save() a.save()
# Confirm can save and it resets the changed fields without hitting # Confirm can save and it resets the changed fields without hitting
@ -1353,7 +1353,7 @@ class DocumentTest(unittest.TestCase):
b.name='world' b.name='world'
b.save() 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): def test_save_cascades(self):