comparison sat/plugins/plugin_exp_pubsub_schema.py @ 2784:76ebecdb9b1e

plugin pubsub schema: handle XHTML fields
author Goffi <goffi@goffi.org>
date Sat, 19 Jan 2019 11:39:02 +0100
parents 95321f233387
children 0b7ce5daee9b
comparison
equal deleted inserted replaced
2783:442ab697f831 2784:76ebecdb9b1e
370 if isinstance(values_list, basestring) or not isinstance( 370 if isinstance(values_list, basestring) or not isinstance(
371 values_list, Iterable 371 values_list, Iterable
372 ): 372 ):
373 values_list = [values_list] 373 values_list = [values_list]
374 if deserialise: 374 if deserialise:
375 if field.fieldType == "boolean": 375 if field.fieldType == u"boolean":
376 values_list = [C.bool(v) for v in values_list] 376 values_list = [C.bool(v) for v in values_list]
377 elif field.fieldType == "text-multi": 377 elif field.fieldType == u"text-multi":
378 # for text-multi, lines must be put on separate values 378 # for text-multi, lines must be put on separate values
379 values_list = list( 379 values_list = list(
380 itertools.chain(*[v.splitlines() for v in values_list]) 380 itertools.chain(*[v.splitlines() for v in values_list])
381 ) 381 )
382 382 elif xml_tools.isXHTMLField(field):
383 elif "jid" in field.fieldType: 383 values_list = [generic.parseXml(v.encode("utf-8"))
384 for v in values_list]
385 elif u"jid" in (field.fieldType or u""):
384 values_list = [jid.JID(v) for v in values_list] 386 values_list = [jid.JID(v) for v in values_list]
385 if "list" in field.fieldType: 387 if u"list" in (field.fieldType or u""):
386 # for lists, we check that given values are allowed in form 388 # for lists, we check that given values are allowed in form
387 allowed_values = [o.value for o in field.options] 389 allowed_values = [o.value for o in field.options]
388 values_list = [v for v in values_list if v in allowed_values] 390 values_list = [v for v in values_list if v in allowed_values]
389 if not values_list: 391 if not values_list:
390 # if values don't map to allowed values, we use default ones 392 # if values don't map to allowed values, we use default ones