summaryrefslogtreecommitdiff
path: root/addons/document
diff options
context:
space:
mode:
authorSbh (Openerp) <sbh@tinyerp.com>2012-06-25 14:51:12 +0530
committerSbh (Openerp) <sbh@tinyerp.com>2012-06-25 14:51:12 +0530
commited3f7fb030523d6fcbc050ebbe1946da1db5a3d1 (patch)
tree998764ffc251108985b0b1579ef7e5a557f3cae2 /addons/document
parent9eb877fee53e7d62a1692a28acc8a0d7a8fb5a57 (diff)
parent06391b79366765df2845c5e1f67adf566b50349a (diff)
[MERGE] Merge with lp:openobject-addons
bzr revid: sbh@tinyerp.com-20120625092112-s7o833jxa988mbz6
Diffstat (limited to 'addons/document')
-rw-r--r--addons/document/document.py4
-rw-r--r--addons/document/document_directory.py4
-rw-r--r--addons/document/document_storage.py60
3 files changed, 34 insertions, 34 deletions
diff --git a/addons/document/document.py b/addons/document/document.py
index c213ca57549..b304f54cec3 100644
--- a/addons/document/document.py
+++ b/addons/document/document.py
@@ -30,7 +30,7 @@ from tools.translate import _
import nodes
import logging
-_loggerdoc = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config['root_path'], 'filestore'))
@@ -57,7 +57,7 @@ class document_file(osv.osv):
parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid)
if not parent_id:
- _loggerdoc.warning("at _attach_parent_id(), still not able to set the parent!")
+ _logger.warning("at _attach_parent_id(), still not able to set the parent!")
return False
if ids is not None:
diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py
index d7d2e4763c7..03b2dcc47bf 100644
--- a/addons/document/document_directory.py
+++ b/addons/document/document_directory.py
@@ -25,7 +25,7 @@ from osv.orm import except_orm
import logging
import nodes
from tools.translate import _
-_loggerdir = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
class document_directory(osv.osv):
_name = 'document.directory'
_description = 'Directory'
@@ -79,7 +79,7 @@ class document_directory(osv.osv):
return root_id
except Exception, e:
- _loggerdir.warning('Cannot set directory root:'+ str(e))
+ _logger.warning('Cannot set directory root:'+ str(e))
return False
return objid.browse(cr, uid, mid, context=context).res_id
diff --git a/addons/document/document_storage.py b/addons/document/document_storage.py
index a3a5e0db1fe..339b320e9a7 100644
--- a/addons/document/document_storage.py
+++ b/addons/document/document_storage.py
@@ -37,7 +37,7 @@ import string
import pooler
import nodes
from content_index import cntIndex
-_doclog = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config.get('root_path'), 'filestore'))
@@ -127,7 +127,7 @@ class nodefd_file(nodes.node_descriptor):
mime, icont = cntIndex.doIndex(None, filename=filename,
content_type=None, realfname=fname)
except Exception:
- _doclog.debug('Cannot index file:', exc_info=True)
+ _logger.debug('Cannot index file:', exc_info=True)
pass
try:
@@ -147,7 +147,7 @@ class nodefd_file(nodes.node_descriptor):
cr.commit()
cr.close()
except Exception:
- _doclog.warning('Cannot save file indexed content:', exc_info=True)
+ _logger.warning('Cannot save file indexed content:', exc_info=True)
elif self.mode in ('a', 'a+' ):
try:
@@ -161,7 +161,7 @@ class nodefd_file(nodes.node_descriptor):
cr.commit()
cr.close()
except Exception:
- _doclog.warning('Cannot save file appended content:', exc_info=True)
+ _logger.warning('Cannot save file appended content:', exc_info=True)
@@ -188,7 +188,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
- _doclog.error("Incorrect mode %s specified", mode)
+ _logger.error("Incorrect mode %s specified", mode)
raise IOError(errno.EINVAL, "Invalid file mode")
self.mode = mode
@@ -214,7 +214,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
mime, icont = cntIndex.doIndex(data, filename=filename,
content_type=None, realfname=None)
except Exception:
- _doclog.debug('Cannot index file:', exc_info=True)
+ _logger.debug('Cannot index file:', exc_info=True)
pass
try:
@@ -238,7 +238,7 @@ class nodefd_db(StringIO, nodes.node_descriptor):
(out, len(data), par.file_id))
cr.commit()
except Exception:
- _doclog.exception('Cannot update db file #%d for close:', par.file_id)
+ _logger.exception('Cannot update db file #%d for close:', par.file_id)
raise
finally:
cr.close()
@@ -268,7 +268,7 @@ class nodefd_db64(StringIO, nodes.node_descriptor):
elif mode == 'a':
StringIO.__init__(self, None)
else:
- _doclog.error("Incorrect mode %s specified", mode)
+ _logger.error("Incorrect mode %s specified", mode)
raise IOError(errno.EINVAL, "Invalid file mode")
self.mode = mode
@@ -317,7 +317,7 @@ class nodefd_db64(StringIO, nodes.node_descriptor):
(base64.encodestring(data), len(data), par.file_id))
cr.commit()
except Exception:
- _doclog.exception('Cannot update db file #%d for close:', par.file_id)
+ _logger.exception('Cannot update db file #%d for close:', par.file_id)
raise
finally:
cr.close()
@@ -398,7 +398,7 @@ class document_storage(osv.osv):
npath = filter(lambda x: x is not None, npath)
# if self._debug:
- # self._doclog.debug('Npath: %s', npath)
+ # self._logger.debug('Npath: %s', npath)
for n in npath:
if n == '..':
raise ValueError("Invalid '..' element in path")
@@ -409,7 +409,7 @@ class document_storage(osv.osv):
dpath += npath[:-1]
path = os.path.join(*dpath)
if not os.path.isdir(path):
- _doclog.debug("Create dirs: %s", path)
+ _logger.debug("Create dirs: %s", path)
os.makedirs(path)
return path, npath
@@ -447,7 +447,7 @@ class document_storage(osv.osv):
# try to fix their directory.
if mode in ('r','r+'):
if ira.file_size:
- _doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
+ _logger.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
raise IOError(errno.ENOENT, 'No file can be located')
else:
store_fname = self.__get_random_fname(boo.path)
@@ -489,7 +489,7 @@ class document_storage(osv.osv):
# On a migrated db, some files may have the wrong storage type
# try to fix their directory.
if ira.file_size:
- _doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
+ _logger.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
return None
fpath = os.path.join(boo.path, ira.store_fname)
return file(fpath, 'rb').read()
@@ -513,7 +513,7 @@ class document_storage(osv.osv):
# On a migrated db, some files may have the wrong storage type
# try to fix their directory.
if ira.file_size:
- _doclog.warning("ir.attachment #%d does not have a filename, trying the name." %ira.id)
+ _logger.warning("ir.attachment #%d does not have a filename, trying the name." %ira.id)
# sfname = ira.name
fpath = os.path.join(boo.path,ira.store_fname or ira.name)
if os.path.exists(fpath):
@@ -546,7 +546,7 @@ class document_storage(osv.osv):
if boo.readonly:
raise IOError(errno.EPERM, "Readonly medium")
- _doclog.debug( "Store data for ir.attachment #%d" % ira.id)
+ _logger.debug( "Store data for ir.attachment #%d" % ira.id)
store_fname = None
fname = None
if boo.type == 'filestore':
@@ -559,13 +559,13 @@ class document_storage(osv.osv):
fp.write(data)
finally:
fp.close()
- _doclog.debug( "Saved data to %s" % fname)
+ _logger.debug( "Saved data to %s" % fname)
filesize = len(data) # os.stat(fname).st_size
# TODO Here, an old file would be left hanging.
except Exception, e:
- _doclog.warning( "Couldn't save data to %s", path, exc_info=True)
+ _logger.warning( "Couldn't save data to %s", path, exc_info=True)
raise except_orm(_('Error!'), str(e))
elif boo.type == 'db':
filesize = len(data)
@@ -588,12 +588,12 @@ class document_storage(osv.osv):
fp.write(data)
finally:
fp.close()
- _doclog.debug("Saved data to %s", fname)
+ _logger.debug("Saved data to %s", fname)
filesize = len(data) # os.stat(fname).st_size
store_fname = os.path.join(*npath)
# TODO Here, an old file would be left hanging.
except Exception,e :
- _doclog.warning("Couldn't save data:", exc_info=True)
+ _logger.warning("Couldn't save data:", exc_info=True)
raise except_orm(_('Error!'), str(e))
elif boo.type == 'virtual':
@@ -612,7 +612,7 @@ class document_storage(osv.osv):
mime, icont = cntIndex.doIndex(data, ira.datas_fname,
ira.file_type or None, fname)
except Exception:
- _doclog.debug('Cannot index file:', exc_info=True)
+ _logger.debug('Cannot index file:', exc_info=True)
pass
try:
@@ -629,7 +629,7 @@ class document_storage(osv.osv):
file_node.content_type = mime
return True
except Exception, e :
- self._doclog.warning("Couldn't save data:", exc_info=True)
+ self._logger.warning("Couldn't save data:", exc_info=True)
# should we really rollback once we have written the actual data?
# at the db case (only), that rollback would be safe
raise except_orm(_('Error at doc write!'), str(e))
@@ -667,9 +667,9 @@ class document_storage(osv.osv):
try:
os.unlink(fname)
except Exception:
- _doclog.warning("Could not remove file %s, please remove manually.", fname, exc_info=True)
+ _logger.warning("Could not remove file %s, please remove manually.", fname, exc_info=True)
else:
- _doclog.warning("Unknown unlink key %s" % ktype)
+ _logger.warning("Unknown unlink key %s" % ktype)
return True
@@ -699,9 +699,9 @@ class document_storage(osv.osv):
fname = ira.store_fname
if not fname:
- _doclog.warning("Trying to rename a non-stored file")
+ _logger.warning("Trying to rename a non-stored file")
if fname != os.path.join(*npath):
- _doclog.warning("inconsistency in realstore: %s != %s" , fname, repr(npath))
+ _logger.warning("inconsistency in realstore: %s != %s" , fname, repr(npath))
oldpath = os.path.join(path, npath[-1])
newpath = os.path.join(path, new_name)
@@ -739,7 +739,7 @@ class document_storage(osv.osv):
break
par = par.parent_id
if file_node.storage_id != psto:
- _doclog.debug('Cannot move file %r from %r to %r', file_node, file_node.parent, ndir_bro.name)
+ _logger.debug('Cannot move file %r from %r to %r', file_node, file_node.parent, ndir_bro.name)
raise NotImplementedError('Cannot move files between storage media')
if sbro.type in ('filestore', 'db', 'db64'):
@@ -752,9 +752,9 @@ class document_storage(osv.osv):
fname = ira.store_fname
if not fname:
- _doclog.warning("Trying to rename a non-stored file")
+ _logger.warning("Trying to rename a non-stored file")
if fname != os.path.join(*opath):
- _doclog.warning("inconsistency in realstore: %s != %s" , fname, repr(opath))
+ _logger.warning("inconsistency in realstore: %s != %s" , fname, repr(opath))
oldpath = os.path.join(path, opath[-1])
@@ -762,12 +762,12 @@ class document_storage(osv.osv):
npath = filter(lambda x: x is not None, npath)
newdir = os.path.join(*npath)
if not os.path.isdir(newdir):
- _doclog.debug("Must create dir %s", newdir)
+ _logger.debug("Must create dir %s", newdir)
os.makedirs(newdir)
npath.append(opath[-1])
newpath = os.path.join(*npath)
- _doclog.debug("Going to move %s from %s to %s", opath[-1], oldpath, newpath)
+ _logger.debug("Going to move %s from %s to %s", opath[-1], oldpath, newpath)
shutil.move(oldpath, newpath)
store_path = npath[1:] + [opath[-1],]