Mercurial > libervia-backend
diff src/plugins/plugin_exp_pubsub_schema.py @ 2398:3ff9d7a7fe71
core (XMLUI): filters can now be used when converting data form to XMLUI:
they can be used to modify created widgets, this is specially useful to customise well known field.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 27 Oct 2017 18:06:58 +0200 |
parents | 713cedc99752 |
children | 03da3ef5fb5b |
line wrap: on
line diff
--- a/src/plugins/plugin_exp_pubsub_schema.py Fri Oct 27 18:03:35 2017 +0200 +++ b/src/plugins/plugin_exp_pubsub_schema.py Fri Oct 27 18:06:58 2017 +0200 @@ -199,24 +199,27 @@ def _getDataFormItems(self, form_ns='', service='', node='', schema='', max_items=10, item_ids=None, sub_id=None, extra_dict=None, profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service = jid.JID(service) if service else None + if not node: + raise exceptions.DataError(_(u'empty node is not allowed')) if schema: schema = generic.parseXml(schema.encode('utf-8')) else: schema = None max_items = None if max_items == C.NO_LIMIT else max_items extra = self._p.parseExtra(extra_dict) - d = self.getDataFormItems(client, form_ns or None, service, node or None, schema, max_items or None, item_ids, sub_id or None, extra.rsm_request, extra.extra) + d = self.getDataFormItems(client, form_ns or None, service, node, schema, max_items or None, item_ids, sub_id or None, extra.rsm_request, extra.extra) d.addCallback(self._p.serItemsData) return d @defer.inlineCallbacks - def getDataFormItems(self, client, form_ns, service, nodeIdentifier, schema=None, max_items=None, item_ids=None, sub_id=None, rsm_request=None, extra=None): + def getDataFormItems(self, client, form_ns, service, nodeIdentifier, schema=None, max_items=None, item_ids=None, sub_id=None, rsm_request=None, extra=None, filters=None): """Get items known as being data forms, and convert them to XMLUI @param form_ns (unicode, None): namespace of the form None to accept everything, even if form has no namespace @param schema(domish.Element, data_form.Form, None): schema of the node if known if None, it will be retrieved from node + @param filters(dict, None): same as for xml_tools.dataFormResult2XMLUI other parameters as the same as for [getItems] @return (list[unicode]): XMLUI of the forms if an item is invalid (not corresponding to form_ns or not a data_form) @@ -235,7 +238,8 @@ xmlui = xml_tools.dataFormResult2XMLUI( form, schema_form, - prepend = (('label', 'id'),('text', item_elt['id'], u'id')) + prepend = (('label', 'id'),('text', item_elt['id'], u'id')), + filters = filters, ) items_xmlui.append(xmlui) break