use filesystem storage for files (closes #2996454)
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Tue, 09 Jul 2013 15:08:26 +0200
changeset 57 17016266f03f
parent 54 85c0a4436baa
child 58 7cb27796579d
use filesystem storage for files (closes #2996454)
hooks.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hooks.py	Tue Jul 09 15:08:26 2013 +0200
@@ -0,0 +1,17 @@
+from os import makedirs
+from os.path import join, exists
+
+from cubicweb.server import hook
+from cubicweb.server.sources import storages
+
+class ServerStartupHook(hook.Hook):
+    __regid__ = 'drh.serverstartup'
+    events = ('server_startup', 'server_maintenance')
+
+    def __call__(self):
+        bfssdir = join(self.repo.config.appdatahome, 'bfss')
+        if not exists(bfssdir):
+            makedirs(bfssdir)
+            print 'created', bfssdir
+        storage = storages.BytesFileSystemStorage(bfssdir)
+        storages.set_attribute_storage(self.repo, 'File', 'data', storage)