summaryrefslogtreecommitdiff
path: root/addons/document/document.py
diff options
context:
space:
mode:
authorChristophe Simonis <christophe@taupe>2009-01-23 00:52:23 +0100
committerChristophe Simonis <christophe@taupe>2009-01-23 00:52:23 +0100
commit79add8da4a096a1ac3e589201a87f52cbadec80a (patch)
treeaf85a783723e1e2897360c4ce82c9150186c73be /addons/document/document.py
parent27804a10d72f479a4a4d1eaf37f86858b5e3dde4 (diff)
[FIX] locate the filestore directory using tools.config['root_path']
lp bug: https://launchpad.net/bugs/320126 fixed bzr revid: christophe@taupe-20090122235223-ug7tqaftvdcfjugd
Diffstat (limited to 'addons/document/document.py')
-rw-r--r--addons/document/document.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index fd05a984cef..1a429ca5634 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -484,13 +484,16 @@ def create_directory(path):
class document_file(osv.osv):
_inherit = 'ir.attachment'
+
+ def _get_filestore(self, cr):
+ return os.path.join(tools.config['root_path'], 'filestore', cr.dbname)
+
def _data_get(self, cr, uid, ids, name, arg, context):
result = {}
cr.execute('select id,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')')
for id,r,l in cr.fetchall():
try:
- path = os.path.join(os.getcwd(), 'filestore', cr.dbname)
- value = file(os.path.join(path,r), 'rb').read()
+ value = file(os.path.join(self._get_filestore(cr), r), 'rb').read()
result[id] = base64.encodestring(value)
except:
result[id]=''
@@ -507,7 +510,7 @@ class document_file(osv.osv):
if not value:
return True
#if (not context) or context.get('store_method','fs')=='fs':
- path = os.path.join(os.getcwd(), "filestore", cr.dbname)
+ path = self._get_filestore(cr)
if not os.path.isdir(path):
os.makedirs(path)
flag = None
@@ -658,8 +661,7 @@ class document_file(osv.osv):
for f in self.browse(cr, uid, ids, context):
#if f.store_method=='fs':
try:
- path = os.path.join(os.getcwd(), cr.dbname, 'filestore',f.store_fname)
- os.unlink(path)
+ os.unlink(os.path.join(self._get_filestore(cr), f.store_fname))
except:
pass
return super(document_file, self).unlink(cr, uid, ids, context)