comparison sat/plugins/plugin_exp_pubsub_schema.py @ 2603:5d4ac5415b40

plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
author Goffi <goffi@goffi.org>
date Fri, 01 Jun 2018 12:21:23 +0200
parents 26edcf3a30eb
children 3e4e78de9cca
comparison
equal deleted inserted replaced
2602:41db2f58c753 2603:5d4ac5415b40
374 sub_id = None 374 sub_id = None
375 extra = self._p.parseExtra(extra_dict) 375 extra = self._p.parseExtra(extra_dict)
376 376
377 return client, service, node, max_items, extra, sub_id 377 return client, service, node, max_items, extra, sub_id
378 378
379 def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None, extra_dict=None, default_node=None, form_ns=None, filters=None, profile_key=C.PROF_KEY_NONE): 379 def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None, extra=None, default_node=None, form_ns=None, filters=None, profile_key=C.PROF_KEY_NONE):
380 """Bridge method to retrieve data from node with schema 380 """Bridge method to retrieve data from node with schema
381 381
382 this method is a helper so dependant plugins can use it directly 382 this method is a helper so dependant plugins can use it directly
383 when adding *Get methods 383 when adding *Get methods
384 """ 384 extra can have the key "labels_as_list" which is a hack to convert
385 client, service, node, max_items, extra, sub_id = self.prepareBridgeGet(service, node, max_items, sub_id, extra_dict, profile_key) 385 labels from textbox to list in XMLUI, which usually render better
386 in final UI.
387 """
388 if filters is None:
389 filters = {}
390 if extra is None:
391 extra = {}
392 # XXX: Q&D way to get list for labels when displaying them, but text when we
393 # have to modify them
394 if C.bool(extra.get('labels_as_list', C.BOOL_FALSE)):
395 filters = filters.copy()
396 filters[u'labels'] = self.textbox2ListFilter
397 client, service, node, max_items, extra, sub_id = self.prepareBridgeGet(service, node, max_items, sub_id, extra, profile_key)
386 d = self.getDataFormItems(client, service, node or None, 398 d = self.getDataFormItems(client, service, node or None,
387 max_items=max_items, 399 max_items=max_items,
388 item_ids=item_ids, 400 item_ids=item_ids,
389 sub_id=sub_id, 401 sub_id=sub_id,
390 rsm_request=extra.rsm_request, 402 rsm_request=extra.rsm_request,