Mercurial > libervia-backend
comparison sat/tools/xml_tools.py @ 2958:e2cb04b381bb
tools (xml_tools): added "read_only" argument in dataFormResult2XMLUI (and use it in plugin pubsub_schema)
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 12 Jun 2019 09:11:28 +0200 |
parents | 48985ef7682f |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2957:8fd8c9f548cd | 2958:e2cb04b381bb |
---|---|
285 parsed_form = data_form.Form.fromElement(form_elt) | 285 parsed_form = data_form.Form.fromElement(form_elt) |
286 dataForm2Widgets(xml_ui, parsed_form, read_only=True) | 286 dataForm2Widgets(xml_ui, parsed_form, read_only=True) |
287 return xml_ui | 287 return xml_ui |
288 | 288 |
289 | 289 |
290 def dataFormResult2XMLUI( | 290 def dataFormResult2XMLUI(result_form, base_form, session_id=None, prepend=None, |
291 result_form, base_form, session_id=None, prepend=None, filters=None | 291 filters=None, read_only=True): |
292 ): | |
293 """Convert data form result to SàT XMLUI. | 292 """Convert data form result to SàT XMLUI. |
294 | 293 |
295 @param result_form (data_form.Form): result form to convert | 294 @param result_form (data_form.Form): result form to convert |
296 @param base_form (data_form.Form): initial form (i.e. of form type "form") | 295 @param base_form (data_form.Form): initial form (i.e. of form type "form") |
297 this one is necessary to reconstruct options when needed (e.g. list elements) | 296 this one is necessary to reconstruct options when needed (e.g. list elements) |
298 @param session_id (unicode): session id to return with the data | 297 @param session_id (unicode): session id to return with the data |
299 @param prepend: same as for [dataForm2Widgets] | 298 @param prepend: same as for [dataForm2Widgets] |
300 @param filters: same as for [dataForm2Widgets] | 299 @param filters: same as for [dataForm2Widgets] |
300 @param read_only: same as for [dataForm2Widgets] | |
301 @return: XMLUI instance | 301 @return: XMLUI instance |
302 """ | 302 """ |
303 # we deepcopy the form because _dataFormField2XMLUIData can modify the value | 303 # we deepcopy the form because _dataFormField2XMLUIData can modify the value |
304 # FIXME: check if it's really important, the only modified value seems to be | 304 # FIXME: check if it's really important, the only modified value seems to be |
305 # the replacement of None by "" on fixed fields | 305 # the replacement of None by "" on fixed fields |
310 base_field = base_form.fields[name] | 310 base_field = base_form.fields[name] |
311 except KeyError: | 311 except KeyError: |
312 continue | 312 continue |
313 field.options = base_field.options[:] | 313 field.options = base_field.options[:] |
314 xml_ui = XMLUI("window", "vertical", session_id=session_id) | 314 xml_ui = XMLUI("window", "vertical", session_id=session_id) |
315 dataForm2Widgets(xml_ui, form, read_only=True, prepend=prepend, filters=filters) | 315 dataForm2Widgets(xml_ui, form, read_only=read_only, prepend=prepend, filters=filters) |
316 return xml_ui | 316 return xml_ui |
317 | 317 |
318 | 318 |
319 def _cleanValue(value): | 319 def _cleanValue(value): |
320 """Workaround method to avoid DBus types with D-Bus bridge. | 320 """Workaround method to avoid DBus types with D-Bus bridge. |