Module: check_mk
Branch: master
Commit: b75f056e744dfac4498f79fd05a386ce0b45a662
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b75f056e744dfa…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Apr 18 10:06:49 2012 +0200
Fix order problem in ListOf
---
ChangeLog | 1 +
web/htdocs/valuespec.py | 18 ++++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 53c3a35..522e9de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,7 @@
urls to prevent too big security issues
* Rule editor: improve sorting of groups and rulesets
* FIX: Escaping single quotes in strings when writing auth.php
+ * FIX: Fix resorting of host tags (was bug in ListOf)
Multisite
* Added config option default_ts_format to configure default timestamp
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 4ee3078..8d35e87 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -624,15 +624,21 @@ class ListOf(ValueSpec):
self._valuespec.value_to_text(v) for v in value])
def from_html_vars(self, varprefix):
- value = []
- n = 0
+ n = 1
+ indexes = {}
while True:
- indexof = html.var(varprefix + "_indexof_%d" % (n+1))
+ indexof = html.var(varprefix + "_indexof_%d" % n)
if indexof == None:
- break;
- value.append(self._valuespec.from_html_vars(
- varprefix + "_%d" % int(indexof)))
+ break
+ indexes[int(indexof)] = n
n += 1
+
+ value = []
+ k = indexes.keys()
+ k.sort()
+ for i in k:
+ val = self._valuespec.from_html_vars(varprefix + "_%d" %
indexes[i])
+ value.append(val)
return value
def validate_datatype(self, value, varprefix):