Fixed Gridfs deletes, added dummy size method that return 0 always, updated docs

This commit is contained in:
Roberto Rosario
2011-03-04 02:12:15 -04:00
parent d0bea8ffeb
commit 9674d4d3ee
5 changed files with 37 additions and 3 deletions

View File

@@ -10,6 +10,10 @@ HOST = u'localhost'
PORT = 27017
DATABASE_NAME = u'document_storage'
#TODO: Implement user settings
#TODO: Implement delete-open soft locking
#TODO :master_slave_connection
class GridFSStorage(Storage):
def __init__(self, *args, **kwargs):
self.db = Connection(host=HOST, port=PORT)[DATABASE_NAME]
@@ -54,9 +58,8 @@ class GridFSStorage(Storage):
def delete(self, name):
oid = self.fs.get_last_version(name)
self.delete(oid)
return True
oid = self.fs.get_last_version(name)._id
self.fs.delete(oid)
def exists(self, name):
@@ -66,6 +69,11 @@ class GridFSStorage(Storage):
def path(self, name):
return force_unicode(name)
def size(self, name):
#TODO: Implement
return 0
def move(self, old_file_name, name, chunk_size=1024*64):
# first open the old file, so that it won't go away

View File

@@ -93,3 +93,9 @@ favicon
http://www.iconfinder.com/icondetails/21581/24/draw_pyramid_icon
by Gnome Project
MongoDB
PyMongo
GridFS

View File

@@ -48,3 +48,6 @@
* Added document link in the OCR document queue list
* Link to manually re queue failed OCR
* Don't separate links (encose object list links with white-space: nowrap;)
2011-Mar 04
* Initial GridFS storage support

View File

@@ -41,3 +41,12 @@
from customstorage import CustomStorage
DOCUMENTS_STORAGE_BACKEND = CustomStorage
* How to enable the GridFS storage backend
- Solution:
Add the following lines to settings.py:
from storage.backends.gridfsstorage import GridFSStorage
DOCUMENTS_STORAGE_BACKEND = GridFSStorage
- Filesystem metadata indexing will not work with this storage backend as
file are inside a MongoDB database and can't be linked (at least for now)

View File

@@ -92,6 +92,14 @@ TODO, WISHLIST
* Save advanced search by metadata setup as a virtual folder
GridFSStorage
============
* Implement user settings
* Implement delete-open soft locking
* Implement master_slave_connection
* if exists adding _ plus a counter - avoid file versioning
ISSUES
===========
* Staging file hash colition when same file with different name, newhash = content hash + filename hash