Implement GridFS storage user settings
This commit is contained in:
@@ -6,22 +6,19 @@ from django.utils.encoding import force_unicode
|
||||
from pymongo import Connection
|
||||
from gridfs import GridFS
|
||||
|
||||
HOST = u'localhost'
|
||||
PORT = 27017
|
||||
DATABASE_NAME = u'document_storage'
|
||||
|
||||
#TODO: Implement user settings
|
||||
#TODO: Implement delete-open soft locking
|
||||
#TODO :master_slave_connection
|
||||
from storage.conf import settings
|
||||
|
||||
|
||||
class GridFSStorage(Storage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.db = Connection(host=HOST, port=PORT)[DATABASE_NAME]
|
||||
self.db = Connection(host=settings.GRIDFS_HOST,
|
||||
port=settings.GRIDFS_PORT)[settings.DATABASE_NAME]
|
||||
self.fs = GridFS(self.db)
|
||||
|
||||
|
||||
def save(self, name, content):
|
||||
#TODO: if exists adding _ plus a counter
|
||||
#TODO: if exists add _ plus a counter
|
||||
while True:
|
||||
try:
|
||||
# This file has a file path that we can move.
|
||||
|
||||
0
apps/storage/conf/__init__.py
Normal file
0
apps/storage/conf/__init__.py
Normal file
6
apps/storage/conf/settings.py
Normal file
6
apps/storage/conf/settings.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
GRIDFS_HOST = getattr(settings, 'STORAGE_GRIDFS_HOST', 'localhost')
|
||||
GRIDFS_PORT = getattr(settings, 'STORAGE_GRIDFS_PORT', 27017)
|
||||
DATABASE_NAME = getattr(settings, 'STORAGE_GRIDFS_DATABASE_NAME', u'document_storage')
|
||||
Reference in New Issue
Block a user