[IMP] error messages during database creation failure, with thanks to Serpent Consulting

bzr revid: xmo@openerp.com-20111121102141-95si5svzfycon9ob
This commit is contained in:
Xavier Morel 2011-11-21 11:21:41 +01:00
commit 69dba424e7
1 changed files with 9 additions and 4 deletions

View File

@ -268,13 +268,18 @@ class Database(openerpweb.Controller):
params['db_lang'],
params['create_admin_pwd']
)
try:
return req.session.proxy("db").create(*create_attrs)
except xmlrpclib.Fault, e:
if e.faultCode and e.faultCode.split(':')[0] == 'AccessDenied':
return {'error': e.faultCode, 'title': 'Create Database'}
return {'error': 'Could not create database !', 'title': 'Create Database'}
if e.faultCode and isinstance(e.faultCode, str)\
and e.faultCode.split(':')[0] == 'AccessDenied':
return {'error': e.faultCode, 'title': 'Database creation error'}
return {
'error': "Could not create database '%s': %s" % (
params['db_name'], e.faultString),
'title': 'Database creation error'
}
@openerpweb.jsonrequest
def drop(self, req, fields):