max_pos += len(str(self.limits[num][1]))
while self._value[num] < self.limits[num][0]:
- self.value[num] += 1
+ self._value[num] += 1
while self._value[num] > self.limits[num][1]:
self._value[num] -= 1
return str(v)
def fromstring(self, value):
- return [int(x) for x in self.saved_value.split(self.seperator)]
+ return [int(x) for x in value.split(self.seperator)]
class ConfigIP(ConfigSequence):
def __init__(self, default):
ConfigSequence.__init__(self, seperator = ".", limits = [(0,255),(0,255),(0,255),(0,255)], default = default)
+
+ def getHTML(self, id):
+ # we definitely don't want leading zeros
+ return '.'.join(["%d" % d for d in self.value])
class ConfigMAC(ConfigSequence):
def __init__(self, default):
item.saved_value = self.stored_values[i]
item.load()
+ def dict(self):
+ res = dict()
+ for index in range(len(self)):
+ res[str(index)] = self[index]
+ return res
+
# same as ConfigSubList, just as a dictionary.
# care must be taken that the 'key' has a proper
# str() method, because it will be used in the config
item.saved_value = self.stored_values[str(key)]
item.load()
+ def dict(self):
+ return self
+
# Like the classes above, just with a more "native"
# syntax.
#
for x in self.content.items.values():
x.load()
+ def dict(self):
+ return self.content.items
+
# the root config object, which also can "pickle" (=serialize)
# down the whole config tree.
#
def __resolveValue(self, pickles, cmap):
if cmap.has_key(pickles[0]):
if len(pickles) > 1:
- return self.__resolveValue(pickles[1:], cmap[pickles[0]].content.items)
+ return self.__resolveValue(pickles[1:], cmap[pickles[0]].dict())
else:
return str(cmap[pickles[0]].value)
return None