1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Now, on deseralization, sets values of "new fields" (those added to class AFTER a serialization) to defaults one. (So, if we have make a class with 3 fields, "a", "b" and "c", and we at a later stage adds "d", if serialiezed data contains only "a" "b" & "c", deseralziation will fill the value of "d" with its default value (if it has one)

This commit is contained in:
Adolfo Gómez 2012-11-28 08:46:07 +00:00
parent 8437c682fd
commit 3decdf3d9e

View File

@ -258,6 +258,17 @@ class gui(object):
data['tooltip'] = _(data['tooltip'])
return data
@property
def defValue(self):
'''
Returns the default value for this field
'''
return self._data['defvalue']
@defValue.setter
def defValue(self, defValue):
self.setDefValue(defValue)
def setDefValue(self, defValue):
'''
Sets the default value of the field·
@ -266,6 +277,7 @@ class gui(object):
defValue: Default value (string)
'''
self._data['defvalue'] = defValue
class TextField(InputField):
'''
@ -750,6 +762,11 @@ class UserInterface(object):
'''
if values == '': # Has nothing
return
# Set all values to defaults ones
for k in self._gui.iterkeys():
self._gui[k].value = self._gui[k].defValue
for txt in values.decode('zip').split('\002'):
k, v = txt.split('\003')
if self._gui.has_key(k):