Fixed bug in FileField, proxy was not getting the grid_id set

This commit is contained in:
martin 2010-06-24 00:56:51 +08:00 committed by Florian Schlachter
parent 9596a25bb9
commit f9057e1a28

View File

@ -542,6 +542,7 @@ class GridFSProxy(object):
return self
def get(self, id=None):
if id: self.grid_id = id
try: return self.fs.get(id or self.grid_id)
except: return None # File has been deleted
@ -611,7 +612,7 @@ class FileField(BaseField):
def to_python(self, value):
# Use stored value (id) to lookup file in GridFS
return self.gridfs.get()
return self.gridfs.get(id=value)
def validate(self, value):
assert isinstance(value, GridFSProxy)