import tools
from tools.translate import _
import nodes
+import logging
DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config['root_path'], 'filestore'))
'parent_id': __get_def_directory
}
_sql_constraints = [
- ('filename_uniq', 'unique (name,parent_id,res_id,res_model)', 'The file name must be unique !')
+ # filename_uniq is not possible in pure SQL
]
def _check_duplication(self, cr, uid, vals, ids=[], op='create'):
name = vals.get('name', False)
r = stor.prepare_unlink(cr, uid, storage_id, f)
if r:
unres.append(r)
+ else:
+ logging.getLogger('document').warning("Unlinking attachment #%s %s that has no storage",
+ f.id, f.name)
res = super(document_file, self).unlink(cr, uid, ids, context)
stor.do_unlink(cr, uid, unres)
return res
if dbro.type == 'directory':
return nodes.node_dir
elif dbro.type == 'ressource':
- assert not dbro.ressource_parent_type_id, \
- "resource and parent_id at #%d: %r" % (dbro.id, dbro.ressource_parent_type_id)
return nodes.node_res_dir
else:
raise ValueError("dir node for %s type", dbro.type)
name=directory.name
if not parent_id:
parent_id=directory.parent_id and directory.parent_id.id or False
+ # TODO fix algo
if not ressource_parent_type_id:
ressource_parent_type_id=directory.ressource_parent_type_id and directory.ressource_parent_type_id.id or False
if not ressource_id:
def create(self, cr, uid, vals, context=None):
if not self._check_duplication(cr, uid, vals):
raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!'))
- if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) :
- raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!'))
+ newname = vals.get('name',False)
+ if newname:
+ for illeg in ('/', '@', '$', '#'):
+ if illeg in newname:
+ raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!'))
return super(document_directory,self).create(cr, uid, vals, context)
# TODO def unlink(...