Merge branch 'v0.4' of http://github.com/schallis/mongoengine into v0.4
This commit is contained in:
commit
2b9c526b47
@ -21,7 +21,7 @@ a document is created to store details about animals, including a photo::
|
|||||||
marmot = Animal('Marmota', 'Sciuridae')
|
marmot = Animal('Marmota', 'Sciuridae')
|
||||||
|
|
||||||
marmot_photo = open('marmot.jpg', 'r') # Retrieve a photo from disk
|
marmot_photo = open('marmot.jpg', 'r') # Retrieve a photo from disk
|
||||||
marmot.photo = marmot_photo # Store the photo in the document
|
marmot.photo = marmot_photo # Store photo in the document
|
||||||
marmot.photo.content_type = 'image/jpeg' # Store metadata
|
marmot.photo.content_type = 'image/jpeg' # Store metadata
|
||||||
|
|
||||||
marmot.save()
|
marmot.save()
|
||||||
@ -40,7 +40,7 @@ Retrieval
|
|||||||
So using the :class:`~mongoengine.FileField` is just like using any other
|
So using the :class:`~mongoengine.FileField` is just like using any other
|
||||||
field. The file can also be retrieved just as easily::
|
field. The file can also be retrieved just as easily::
|
||||||
|
|
||||||
marmot = Animal.objects('Marmota').first()
|
marmot = Animal.objects(genus='Marmota').first()
|
||||||
photo = marmot.photo.read()
|
photo = marmot.photo.read()
|
||||||
content_type = marmot.photo.content_type
|
content_type = marmot.photo.content_type
|
||||||
|
|
||||||
|
@ -614,15 +614,10 @@ class GridFSProxy(object):
|
|||||||
def delete(self):
|
def delete(self):
|
||||||
# Delete file from GridFS, FileField still remains
|
# Delete file from GridFS, FileField still remains
|
||||||
self.fs.delete(self.grid_id)
|
self.fs.delete(self.grid_id)
|
||||||
|
self.grid_id = None
|
||||||
#self.grid_id = None
|
|
||||||
# Doesn't make a difference because will be put back in when
|
|
||||||
# reinstantiated We should delete all the metadata stored with the
|
|
||||||
# file too
|
|
||||||
|
|
||||||
def replace(self, file, **kwargs):
|
def replace(self, file, **kwargs):
|
||||||
self.delete()
|
self.delete()
|
||||||
self.grid_id = None
|
|
||||||
self.put(file, **kwargs)
|
self.put(file, **kwargs)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user