From 7d83c0dbeb36a928b902f9afcc3091cc53265788 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 22 Sep 2008 10:47:01 +0000 Subject: [PATCH] create directory if it does not exist git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2898 fd906abe-77d9-0310-91a1-e0d9ade77398 --- storage/filesystem.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/filesystem.py b/storage/filesystem.py index 68b1027..bb23ac9 100644 --- a/storage/filesystem.py +++ b/storage/filesystem.py @@ -50,10 +50,13 @@ class FileSystemStorage(object): def setData(self, address, data, params={}): subDir = params.get('subdirectory') fn = self.getDir(address, subDir) + directory = os.path.dirname(fn) + if not os.path.exists(directory): + os.makedirs(directory) f = open(fn, 'wb') f.write(data) f.close() - print 'cybertools.storage: file %s written' % fn + #print 'cybertools.storage: file %s written' % fn # TODO: transaction management: # write to temp file in subDir, keep address in internal dictionary # transaction.manager.get().join(FSSDataManager(address, temp))