# HG changeset patch # User Nicolas Chauvat <nicolas.chauvat@logilab.fr> # Date 1373375306 -7200 # Tue Jul 09 15:08:26 2013 +0200 # Node ID 17016266f03f5f7e4b65d3d271675a5bd7bb6dc2 # Parent 85c0a4436baadc9d981e98304ae6c46112d2464a use filesystem storage for files (closes #2996454) diff --git a/hooks.py b/hooks.py new file mode 100644 --- /dev/null +++ b/hooks.py @@ -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)