Module: check_mk
Branch: master
Commit: 1e87cc61ca704a8459385560fce67943c8237b97
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1e87cc61ca704a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jun 18 16:04:51 2012 +0200
ValueSpec DropdownChoice: handle case with no choices
---
web/htdocs/valuespec.py | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 76aea43..2219a3c 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -757,7 +757,11 @@ class DropdownChoice(ValueSpec):
return self._choices()
def canonical_value(self):
- return self.choices()[0][0]
+ choices = self.choices()
+ if len(choices) > 0:
+ return choices[0][0]
+ else:
+ return None
def render_input(self, varprefix, value):
if self._label:
@@ -769,7 +773,9 @@ class DropdownChoice(ValueSpec):
options.append((str(n),) + entry[1:])
if entry[0] == value:
defval = str(n)
- if len(options[0]) == 3:
+ if len(options) == 0:
+ html.write(_("There are no options to select from"))
+ elif len(options[0]) == 3:
html.icon_select(varprefix, options, defval)
else:
html.select(varprefix, options, defval)