plugin pubsub schema: fixed XML field handling in sendDataFormItem
This commit is contained in:
parent
adf7621495
commit
d2a51169b2
1 changed files with 14 additions and 4 deletions
|
|
@ -405,15 +405,25 @@ class PubsubSchema(object):
|
|||
values_list = field.values
|
||||
elif field.ext_type == 'xml':
|
||||
# FIXME: XML elements are not handled correctly, we need to know if we
|
||||
# actual XML/XHTML, or text to escape
|
||||
# have actual XML/XHTML, or text to escape
|
||||
for idx, value in enumerate(values_list[:]):
|
||||
if not isinstance(value, domish.Element):
|
||||
if isinstance(value, domish.Element):
|
||||
if (field.value and (value.name != field.value.name
|
||||
or value.uri != field.value.uri)):
|
||||
# the element is not the one expected in form, so we create the right element
|
||||
# to wrap the current value
|
||||
wrapper_elt = domish.Element((field.value.uri, field.value.name))
|
||||
wrapper_elt.addChild(value)
|
||||
values_list[idx] = wrapper_elt
|
||||
else:
|
||||
# we have to convert the value to a domish.Element
|
||||
if field.value and field.value.uri == C.NS_XHTML:
|
||||
div_elt = domish.Element((C.NS_XHTML, 'div'))
|
||||
div_elt.addContent(str(value))
|
||||
values_list[idx] = div_elt
|
||||
else:
|
||||
raise NotImplementedError
|
||||
else:
|
||||
# only XHTML fields are handled for now
|
||||
raise NotImplementedError
|
||||
|
||||
field.values = values_list
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue