181 |
|
|
182 |
# TODO: from property type: add more tests to see if the new value is valid |
# TODO: from property type: add more tests to see if the new value is valid |
183 |
|
|
184 |
if propertydef.gnue_type == "id" or \ |
if value == "": |
185 |
|
value = None |
186 |
|
elif propertydef.gnue_type == "id" or \ |
187 |
propertydef.gnue_type == "string": |
propertydef.gnue_type == "string": |
188 |
# String property (the id is actually a string, too) |
# String property (the id is actually a string, too) |
189 |
if value == "": |
if type (value) is not types.StringType: |
190 |
value = None |
value = str (value) |
191 |
else: |
# decode unicode values from utf-8 |
192 |
if type (value) is not types.StringType: |
value = unicode (value, 'utf-8') |
|
value = str (value) |
|
|
# decode unicode values from utf-8 |
|
|
value = unicode (value, 'utf-8') |
|
193 |
|
|
194 |
elif propertydef.gnue_type == "number": |
elif propertydef.gnue_type == "number": |
195 |
# TODO: check if value is an number |
# TODO: check if value is an number |
206 |
|
|
207 |
elif propertydef.gnue_type == "boolean": |
elif propertydef.gnue_type == "boolean": |
208 |
# Boolean property |
# Boolean property |
209 |
if value == "": |
if value in [0, "0", "f", "F", "false", "FALSE", "n", "N", "no", "NO"]: |
|
value = None |
|
|
elif value in [0, "0", "f", "F", "false", "FALSE", "n", "N", "no", "NO"]: |
|
210 |
value = 0 |
value = 0 |
211 |
elif value in [1, "1", "t", "T", "true", "true", "y", "Y", "yes", "YES"]: |
elif value in [1, "1", "t", "T", "true", "true", "y", "Y", "yes", "YES"]: |
212 |
value = 1 |
value = 1 |