From 9674d4d3ee794038c772a165a584836b22629605 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 4 Mar 2011 02:12:15 -0400 Subject: [PATCH] Fixed Gridfs deletes, added dummy size method that return 0 always, updated docs --- apps/storage/backends/gridfsstorage.py | 14 +++++++++++--- docs/CREDITS | 6 ++++++ docs/Changelog.txt | 3 +++ docs/FAQ | 9 +++++++++ docs/TODO | 8 ++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/apps/storage/backends/gridfsstorage.py b/apps/storage/backends/gridfsstorage.py index c6923c342c..18c8cc5e07 100644 --- a/apps/storage/backends/gridfsstorage.py +++ b/apps/storage/backends/gridfsstorage.py @@ -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 diff --git a/docs/CREDITS b/docs/CREDITS index 4acf8bd9d9..7b8c62ee42 100755 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -93,3 +93,9 @@ favicon http://www.iconfinder.com/icondetails/21581/24/draw_pyramid_icon by Gnome Project +MongoDB + +PyMongo + +GridFS + diff --git a/docs/Changelog.txt b/docs/Changelog.txt index bfbcc38ee4..d130949985 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -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 diff --git a/docs/FAQ b/docs/FAQ index 4f7b771941..083af1b599 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -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) diff --git a/docs/TODO b/docs/TODO index 053ddcc01a..e3c5197649 100755 --- a/docs/TODO +++ b/docs/TODO @@ -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