Mercurial > libervia-backend
comparison frontends/src/tools/xmlui.py @ 864:241f6baa6687
frontends: fix typos, do not use logging in the xmlui tools:
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 25 Feb 2014 10:59:05 +0100 |
parents | 1fe00f0c9a91 |
children | 3ee2ec7ec010 |
comparison
equal
deleted
inserted
replaced
863:97ee7594c788 | 864:241f6baa6687 |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat_frontends.constants import Const | 21 from sat_frontends.constants import Const |
22 from logging import debug, info, warning, error | 22 from sat.core.exceptions import DataError |
23 | 23 |
24 | 24 |
25 class InvalidXMLUI(Exception): | 25 class InvalidXMLUI(Exception): |
26 pass | 26 pass |
27 | 27 |
235 cont._xmlui_callback_id = callback_id | 235 cont._xmlui_callback_id = callback_id |
236 cont._xmluiOnSelect(self.onAdvListSelect) | 236 cont._xmluiOnSelect(self.onAdvListSelect) |
237 | 237 |
238 self._parseChilds(cont, node, ('row',), data) | 238 self._parseChilds(cont, node, ('row',), data) |
239 else: | 239 else: |
240 warning(_("Unknown container [%s], using default one") % type_) | 240 print(_("Unknown container [%s], using default one") % type_) |
241 cont = self.widget_factory.createVerticalContainer(parent) | 241 cont = self.widget_factory.createVerticalContainer(parent) |
242 self._parseChilds(cont, node, ('widget', 'container')) | 242 self._parseChilds(cont, node, ('widget', 'container')) |
243 try: | 243 try: |
244 parent._xmluiAppend(cont) | 244 parent._xmluiAppend(cont) |
245 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError | 245 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError |
310 elif type_=="button": | 310 elif type_=="button": |
311 callback_id = node.getAttribute("callback") | 311 callback_id = node.getAttribute("callback") |
312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) | 312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) |
313 ctrl._xmlui_param_id = (callback_id,[field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) | 313 ctrl._xmlui_param_id = (callback_id,[field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) |
314 else: | 314 else: |
315 error(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) | 315 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) |
316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) | 316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) |
317 | 317 |
318 if self.type == 'param': | 318 if self.type == 'param': |
319 try: | 319 try: |
320 ctrl._xmluiOnChange(self.onParamChange) | 320 ctrl._xmluiOnChange(self.onParamChange) |
321 ctrl._param_category = self._current_category | 321 ctrl._param_category = self._current_category |
322 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError | 322 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError |
323 if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)): | 323 if not isinstance(ctrl, (EmptyWidget, TextWidget, LabelWidget, JidWidget)): |
324 warning(_("No change listener on [%s]" % ctrl)) | 324 print(_("No change listener on [%s]") % ctrl) |
325 | 325 |
326 ctrl._xmlui_name = name | 326 ctrl._xmlui_name = name |
327 parent._xmluiAppend(ctrl) | 327 parent._xmluiAppend(ctrl) |
328 | 328 |
329 else: | 329 else: |
382 widgets = ctrl._xmluiGetSelectedWidgets() | 382 widgets = ctrl._xmluiGetSelectedWidgets() |
383 for wid in widgets: | 383 for wid in widgets: |
384 try: | 384 try: |
385 name = self.escape(wid._xmlui_name) | 385 name = self.escape(wid._xmlui_name) |
386 value = wid._xmluiGetValue() | 386 value = wid._xmluiGetValue() |
387 ret[name] = value | 387 data[name] = value |
388 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError | 388 except (AttributeError, TypeError): # XXX: TypeError is here because pyjamas raise a TypeError instead of an AttributeError |
389 pass | 389 pass |
390 idx = ctrl._xmluiGetSelectedIndex() | 390 idx = ctrl._xmluiGetSelectedIndex() |
391 if idx is not None: | 391 if idx is not None: |
392 data['index'] = idx | 392 data['index'] = idx |
393 callback_id = ctrl._xmlui_callback_id | 393 callback_id = ctrl._xmlui_callback_id |
394 if callback_id is None: | 394 if callback_id is None: |
395 warning(_("No callback_id found")) | 395 print(_("No callback_id found")) |
396 return | 396 return |
397 self._xmluiLaunchAction(callback_id, data) | 397 self._xmluiLaunchAction(callback_id, data) |
398 | 398 |
399 def onButtonPress(self, button): | 399 def onButtonPress(self, button): |
400 """ Called when an XMLUI button is clicked | 400 """ Called when an XMLUI button is clicked |
431 if self.session_id is not None: | 431 if self.session_id is not None: |
432 data["session_id"] = self.session_id | 432 data["session_id"] = self.session_id |
433 self._xmluiLaunchAction(self.submit_id, data) | 433 self._xmluiLaunchAction(self.submit_id, data) |
434 | 434 |
435 else: | 435 else: |
436 warning (_("The form data is not sent back, the type is not managed properly")) | 436 print(_("The form data is not sent back, the type is not managed properly")) |
437 self._xmluiClose() | 437 self._xmluiClose() |
438 | 438 |
439 def onFormCancelled(self, ignore=None): | 439 def onFormCancelled(self, ignore=None): |
440 """ Called when a form is cancelled """ | 440 """ Called when a form is cancelled """ |
441 debug(_("Cancelling form")) | 441 print(_("Cancelling form")) |
442 self._xmluiClose() | 442 self._xmluiClose() |
443 | |
444 | 443 |
445 def onSaveParams(self, ignore=None): | 444 def onSaveParams(self, ignore=None): |
446 """ Params are saved, we send them to backend | 445 """ Params are saved, we send them to backend |
447 self.type must be param | 446 self.type must be param |
448 | 447 |