comparison frontends/src/wix/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
22 import wx 22 import wx
23 import pdb 23 import pdb
24 from xml.dom import minidom 24 from xml.dom import minidom
25 from logging import debug, info, warning, error 25 from logging import debug, info, warning, error
26 from sat.tools.jid import JID 26 from sat.tools.jid import JID
27
28 SAT_FORM_PREFIX = "SAT_FORM_"
27 29
28 30
29 class XMLUI(wx.Frame): 31 class XMLUI(wx.Frame):
30 """Create an user interface from a SàT xml""" 32 """Create an user interface from a SàT xml"""
31 33
214 def onFormSubmitted(self, event): 216 def onFormSubmitted(self, event):
215 """Called when submit button is clicked""" 217 """Called when submit button is clicked"""
216 debug(_("Submitting form")) 218 debug(_("Submitting form"))
217 selected_values = [] 219 selected_values = []
218 for ctrl_name in self.ctrl_list: 220 for ctrl_name in self.ctrl_list:
221 escaped = u"%s%s" % (SAT_FORM_PREFIX, ctrl_name)
219 ctrl = self.ctrl_list[ctrl_name] 222 ctrl = self.ctrl_list[ctrl_name]
220 if isinstance(ctrl['control'], wx.ListBox): 223 if isinstance(ctrl['control'], wx.ListBox):
221 label = ctrl['control'].GetStringSelection() 224 label = ctrl['control'].GetStringSelection()
222 value = ctrl['attr_map'][label] 225 value = ctrl['attr_map'][label]
223 selected_values.append((ctrl_name, value)) 226 selected_values.append((escaped, value))
224 elif isinstance(ctrl['control'], wx.CheckBox): 227 elif isinstance(ctrl['control'], wx.CheckBox):
225 selected_values.append((ctrl_name, "true" if ctrl['control'].GetValue() else "false")) 228 selected_values.append((escaped, "true" if ctrl['control'].GetValue() else "false"))
226 else: 229 else:
227 selected_values.append((ctrl_name, ctrl['control'].GetValue())) 230 selected_values.append((escaped, ctrl['control'].GetValue()))
228 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned 231 if self.misc.has_key('action_back'): #FIXME FIXME FIXME: WTF ! Must be cleaned
229 id = self.misc['action_back']("SUBMIT",self.misc['target'], selected_values) 232 id = self.misc['action_back']("SUBMIT",self.misc['target'], selected_values)
230 self.host.current_action_ids.add(id) 233 self.host.current_action_ids.add(id)
231 elif self.misc.has_key('callback'): 234 elif self.misc.has_key('callback'):
232 self.misc['callback'](selected_values) 235 self.misc['callback'](selected_values)