Skip to content

Commit

Permalink
[IMP] server_environment_ir_config_parameter: handle empty values better
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Nov 20, 2016
1 parent a3eecf2 commit f8ba4e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions server_environment_files_sample/dev/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ lib_path = /myHome/lib/wkhtmltopdf-linux-i386-0-9-9

[ir.config_parameter]
ircp_from_config=config_value
ircp_empty=
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def get_param(self, cr, uid, key, default=False, context=None):
cr, uid, key, default=None, context=context)
if serv_config.has_option(SECTION, key):
cvalue = serv_config.get(SECTION, key)
if not cvalue:
raise UserError(_("Key %s is empty in "
"server_environment_file") %
(key, ))
if cvalue != value:
# we write in db on first access;
# should we have preloaded values in database at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ def test_set_param_2(self):
res.unlink()
res = self.ICP.search([('key', '=', 'some.param')])
self.assertFalse(res)

def test_empty(self):
""" Empty config values cause error """
with self.assertRaises(UserError):
self.ICP.get_param('ircp_empty')
self.assertEqual(self.ICP.get_param('ircp_nonexistant'), False)

0 comments on commit f8ba4e9

Please sign in to comment.