forked from shaba/openuds
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:
parent
8437c682fd
commit
3decdf3d9e
@ -258,6 +258,17 @@ class gui(object):
|
|||||||
data['tooltip'] = _(data['tooltip'])
|
data['tooltip'] = _(data['tooltip'])
|
||||||
return data
|
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):
|
def setDefValue(self, defValue):
|
||||||
'''
|
'''
|
||||||
Sets the default value of the field·
|
Sets the default value of the field·
|
||||||
@ -267,6 +278,7 @@ class gui(object):
|
|||||||
'''
|
'''
|
||||||
self._data['defvalue'] = defValue
|
self._data['defvalue'] = defValue
|
||||||
|
|
||||||
|
|
||||||
class TextField(InputField):
|
class TextField(InputField):
|
||||||
'''
|
'''
|
||||||
This represents a text field.
|
This represents a text field.
|
||||||
@ -750,6 +762,11 @@ class UserInterface(object):
|
|||||||
'''
|
'''
|
||||||
if values == '': # Has nothing
|
if values == '': # Has nothing
|
||||||
return
|
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'):
|
for txt in values.decode('zip').split('\002'):
|
||||||
k, v = txt.split('\003')
|
k, v = txt.split('\003')
|
||||||
if self._gui.has_key(k):
|
if self._gui.has_key(k):
|
||||||
|
Loading…
Reference in New Issue
Block a user