comparison frontends/src/jp/cmd_pubsub.py @ 2280:4bc9a2c2d6c9

jp (pubsub, common): fixed last item edition (keep item id instead of creating a new one)
author Goffi <goffi@goffi.org>
date Wed, 28 Jun 2017 20:28:24 +0200
parents e2f96cd1887b
children 4af1805cc6df
comparison
equal deleted inserted replaced
2279:e2f96cd1887b 2280:4bc9a2c2d6c9
329 self.host.quit(1) 329 self.host.quit(1)
330 items = [item] if item is not None else [] 330 items = [item] if item is not None else []
331 item_raw = self.host.bridge.psItemsGet(service, node, 1, items, "", {}, self.profile)[0][0] 331 item_raw = self.host.bridge.psItemsGet(service, node, 1, items, "", {}, self.profile)[0][0]
332 parser = etree.XMLParser(remove_blank_text=True) 332 parser = etree.XMLParser(remove_blank_text=True)
333 item_elt = etree.fromstring(item_raw, parser) 333 item_elt = etree.fromstring(item_raw, parser)
334 item_id = item_elt.get('id')
334 try: 335 try:
335 payload = item_elt[0] 336 payload = item_elt[0]
336 except IndexError: 337 except IndexError:
337 self.disp(_(u'Item has not payload'), 1) 338 self.disp(_(u'Item has not payload'), 1)
338 return u'' 339 return u''
339 return etree.tostring(payload, encoding="unicode", pretty_print=True) 340 return etree.tostring(payload, encoding="unicode", pretty_print=True), item_id
340 341
341 def start(self): 342 def start(self):
342 self.pubsub_service, self.pubsub_node, self.pubsub_item, content_file_path, content_file_obj = self.getItemPath(self.args.item) 343 self.pubsub_service, self.pubsub_node, self.pubsub_item, content_file_path, content_file_obj = self.getItemPath(self.args.item)
343 344
344 self.edit(content_file_path, content_file_obj) 345 self.edit(content_file_path, content_file_obj)