comparison frontends/src/primitivus/xmlui.py @ 762:aed7d99276b8

core (xml_tools), frontends: added a prefix to XMLUI form names in result data, to avoid name conflicts (e.g.: if a form has name "submit", and this name is also used internally by SàT)
author Goffi <goffi@goffi.org>
date Tue, 24 Dec 2013 15:43:22 +0100
parents 73a0077f80cc
children bfabeedbf32e
comparison
equal deleted inserted replaced
761:2f8d72226bc0 762:aed7d99276b8
19 19
20 import urwid 20 import urwid
21 from urwid_satext import sat_widgets 21 from urwid_satext import sat_widgets
22 from logging import debug, info, warning, error 22 from logging import debug, info, warning, error
23 from xml.dom import minidom 23 from xml.dom import minidom
24
25
26 SAT_FORM_PREFIX = "SAT_FORM_"
24 27
25 def getText(node): 28 def getText(node):
26 """Get child text nodes 29 """Get child text nodes
27 @param node: dom Node 30 @param node: dom Node
28 @return: joined unicode text of all nodes 31 @return: joined unicode text of all nodes
252 self.param_changed.add(widget) 255 self.param_changed.add(widget)
253 256
254 def onFormSubmitted(self, button): 257 def onFormSubmitted(self, button):
255 selected_values = [] 258 selected_values = []
256 for ctrl_name in self.ctrl_list: 259 for ctrl_name in self.ctrl_list:
260 escaped = u"%s%s" % (SAT_FORM_PREFIX, ctrl_name)
257 ctrl = self.ctrl_list[ctrl_name] 261 ctrl = self.ctrl_list[ctrl_name]
258 if isinstance(ctrl['control'], sat_widgets.List): 262 if isinstance(ctrl['control'], sat_widgets.List):
259 selected_values.append((ctrl_name, u'\t'.join([option.value for option in ctrl['control'].getSelectedValues()]))) 263 selected_values.append((escaped, u'\t'.join([option.value for option in ctrl['control'].getSelectedValues()])))
260 elif isinstance(ctrl['control'], urwid.CheckBox): 264 elif isinstance(ctrl['control'], urwid.CheckBox):
261 selected_values.append((ctrl_name, "true" if ctrl['control'].get_state() else "false")) 265 selected_values.append((escaped, "true" if ctrl['control'].get_state() else "false"))
262 else: 266 else:
263 selected_values.append((ctrl_name, ctrl['control'].get_edit_text())) 267 selected_values.append((escaped, ctrl['control'].get_edit_text()))
264 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned 268 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned
265 raise NotImplementedError 269 raise NotImplementedError
266 elif 'callback' in self.misc: # FIXME: this part is not needed anymore 270 elif 'callback' in self.misc: # FIXME: this part is not needed anymore
267 try: 271 try:
268 self.misc['callback'](selected_values, submit_id=self.submit_id, *self.misc['callback_args']) 272 self.misc['callback'](selected_values, submit_id=self.submit_id, *self.misc['callback_args'])