comparison src/plugins/plugin_exp_pubsub_schema.py @ 2388:4c883d1c3e81

plugin schema: when publishing a schema, check that values of list are allowed, else use default value
author Goffi <goffi@goffi.org>
date Fri, 20 Oct 2017 08:40:54 +0200
parents 2e05921df16a
children 713cedc99752
comparison
equal deleted inserted replaced
2387:a59f2abd970e 2388:4c883d1c3e81
283 if deserialise: 283 if deserialise:
284 if field.fieldType == 'boolean': 284 if field.fieldType == 'boolean':
285 values_list = [C.bool(v) for v in values_list] 285 values_list = [C.bool(v) for v in values_list]
286 elif 'jid' in field.fieldType: 286 elif 'jid' in field.fieldType:
287 values_list = [jid.JID(v) for v in values_list] 287 values_list = [jid.JID(v) for v in values_list]
288 if 'list' in field.fieldType:
289 # for lists, we check that given values are allowed in form
290 allowed_values = [o.value for o in field.options]
291 values_list = [v for v in values_list if v in allowed_values]
292 if not values_list:
293 # if values don't map to allowed values, we use default ones
294 values_list = field.values
288 field.values = values_list 295 field.values = values_list
289 296
290 yield self._p.sendItem(client, service, nodeIdentifier, form.toElement(), item_id, extra) 297 yield self._p.sendItem(client, service, nodeIdentifier, form.toElement(), item_id, extra)
291 298
292 299