Open djay opened 4 years ago
@mauritsvanrees @jensens So for example an incorrect XML generated from a query is
<action type="collective.contentrules.parentchild.ChildAction">
<property name="query">
<element>
<element key="i">portal_type</element>
<element key="o">plone.app.querystring.operation.selection.any</element>
<element key="v">[u'audio_resource', u'external_resource', u'resource', u'video_resource']</element>
</element>
</property>
<property name="action_source">rule-5</property>
</action>
as seen in https://github.com/collective/collective.contentrules.parentchild/issues/3
@mauritsvanrees @jensens The only other way I can see of fixing this outside of querystring/querywidget is to change supermodel to introduce new XML attribute so we have something like this
<action type="collective.contentrules.parentchild.ChildAction">
<property name="query">
<element>
<element key="i">portal_type</element>
<element key="o">plone.app.querystring.operation.selection.any</element>
<element key="v" encoding="json">['audio_resource', 'external_resource', 'resource', 'video_resource']</element>
</element>
</property>
<property name="action_source">rule-5</property>
</action>
But it still feels like querywidget is abusing a bug in dexterity/z3cform that is allowing it to store a List in a TextLine field. Or supermodel ignores the schema if the value doesn't match and it export and import as
<action type="collective.contentrules.parentchild.ChildAction">
<property name="query">
<element>
<element key="i">portal_type</element>
<element key="o">plone.app.querystring.operation.selection.any</element>
<element key="v"><element>audio</element><element>external_resource</element><element>resource</element>,<element>video_resource</element></element>
</element>
</property>
<property name="action_source">rule-5</property>
</action>
The suggested schema of List of dicts with values of type TextLine seems incorrect for the data and the widget. The value_type can actually be List or Str and maybe other things. Somehow this widget gets around this and manages to store lists where a TextLine is expected. However during serialisation using super model the lists get converted to python strings and then aren't parsed when read back in.
I'm not sure if this is a question or a bug but any idea how to solve or a workaround? @mauritsvanrees @jensens ? Maybe the converter (and the plone.app.querystring parser) need to attempt to parse strings into lists? Or perhaps the widget should always be storing JSON into this value?