# you can overide this for fancy default handling
def load(self):
- if self.saved_value is None:
+ sv = self.saved_value
+ if sv is None:
self.value = self.default
else:
- self.value = self.fromstring(self.saved_value)
+ self.value = self.fromstring(sv)
def tostring(self, value):
return str(value)
self.load()
def isChanged(self):
- if self.saved_value is None and self.value == self.default:
+ sv = self.saved_value
+ if sv is None and self.value == self.default:
return False
- return self.tostring(self.value) != self.saved_value
+ return self.tostring(self.value) != sv
def changed(self):
for x in self.notifiers:
class ConfigPassword(ConfigText):
def __init__(self, default = "", fixed_size = False, visible_width = False, censor = "*"):
- ConfigText.__init__(self, default = "", fixed_size = fixed_size, visible_width = visible_width)
+ ConfigText.__init__(self, default = default, fixed_size = fixed_size, visible_width = visible_width)
self.censor_char = censor
self.hidden = True
return eval(val)
def load(self):
- if self.saved_value is None:
+ sv = self.saved_value
+ if sv is None:
tmp = self.default
else:
- tmp = self.fromstring(self.saved_value)
+ tmp = self.fromstring(sv)
self.locations = [[x, None, False, False] for x in tmp]
self.refreshMountpoints()
for x in self.locations:
self.saved_value = self.tostring([x[0] for x in self.locations])
def isChanged(self):
- if self.saved_value is None and self.locations == []:
+ sv = self.saved_value
+ if val is None and self.locations == []:
return False
- return self.tostring([x[0] for x in self.locations]) != self.saved_value
+ return self.tostring([x[0] for x in self.locations]) != sv
def mountpointsChanged(self, action, dev):
print "Mounts changed: ", action, dev
self[int(key)].saved_value = val
saved_value = property(getSavedValue, setSavedValue)
-
+
def append(self, item):
i = str(len(self))
list.append(self, item)
def getSavedValue(self):
res = {}
for (key, val) in self.items():
- if val.saved_value is not None:
- res[str(key)] = val.saved_value
+ sv = val.saved_value
+ if sv is not None:
+ res[str(key)] = sv
return res
def setSavedValue(self, values):
def getSavedValue(self):
res = self.content.stored_values
for (key, val) in self.content.items.items():
- if val.saved_value is not None:
- res[key] = val.saved_value
+ sv = val.saved_value
+ if sv is not None:
+ res[key] = sv
elif key in res:
del res[key]
-
return res
def setSavedValue(self, values):