Module: check_mk
Branch: master
Commit: 3600a1ba9bc80a974b076e06caf6f7d9a71ed045
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3600a1ba9bc80a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun May 27 12:50:31 2012 +0200
Fix handling with optional keys in ValueSpec Dict
---
web/htdocs/valuespec.py | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 1a5c77d..cde37d2 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1620,8 +1620,19 @@ class Dictionary(ValueSpec):
def __init__(self, **kwargs):
ValueSpec.__init__(self, **kwargs)
self._elements = kwargs["elements"]
- self._optional_keys = kwargs.get("optional_keys", True)
- self._required_keys = kwargs.get("required_keys", [])
+ if "optional_keys" in kwargs:
+ ok = kwargs["optional_keys"]
+ if type(ok) == list:
+ self._required_keys = \
+ [ e[0] for e in self._elements if e[0] not in ok ]
+ self._optional_keys = True
+ elif ok:
+ self._optional_keys = True
+ else:
+ self._optional_keys = False
+ else:
+ self._optional_keys = False
+ self._required_keys = kwargs.get("required_keys", [])
self._columns = kwargs.get("columns", 1) # possible: 1 or 2
self._render = kwargs.get("render", "normal") # also:
"form" -> use forms.section()