tools (xmlui): changeContainer do not create a new one when the current one already fits

This commit is contained in:
souliane 2015-08-21 14:58:42 +02:00
commit ab6b04b898

View file

@ -121,7 +121,7 @@ def dataForm2Widgets(form_ui, form, read_only=False):
def dataForm2XMLUI(form, submit_id, session_id=None, read_only=False):
"""Take a data form (XEP-0004, Wokkel's implementation) and convert it to a SàT XMLUI.
"""Take a data form (Wokkel's XEP-0004 implementation) and convert it to a SàT XMLUI.
@param form (data_form.Form): a Form instance
@param submit_id (unicode): callback id to call when submitting form
@ -134,18 +134,18 @@ def dataForm2XMLUI(form, submit_id, session_id=None, read_only=False):
def dataFormResult2AdvancedList(xmlui, form_xml):
"""Take a raw data form (not parsed by XEP-0004) and convert it to an advanced list.
"""Take a raw data form result (not parsed by Wokkel's XEP-0004 implementation) and convert it to an advanced list.
The raw data form is used because Wokkel doesn't manage result items parsing yet.
@param xmlui (XMLUI): the XMLUI where the AdvancedList will be added
@param form_xml (domish.Element): element of the data form
@return: AdvancedList element
@return: the completed XMLUI instance
"""
headers = {}
try:
reported_elt = form_xml.elements('jabber:x:data', 'reported').next()
except StopIteration:
raise exceptions.DataError("Couldn't find expected <reported> tag")
raise exceptions.DataError("Couldn't find expected <reported> tag in %s" % form_xml.toXml())
for elt in reported_elt.elements():
if elt.name != "field":
@ -364,8 +364,14 @@ class Element(object):
self.parent = parent
def append(self, child):
"""Append a child to this element.
@param child (Element): child element
@return: the added child Element
"""
self.elem.appendChild(child.elem)
child.parent = self
return child
class TopElement(Element):
@ -847,7 +853,7 @@ class ButtonWidget(Widget):
@param callback_id: callback which will be called if button is pressed
@param value: label of the button
@fields_back: list of names of field to give back when pushing the button
@param fields_back: list of names of field to give back when pushing the button
@param name: name
@param parent: parent container
"""
@ -1166,7 +1172,8 @@ class XMLUI(object):
@param container: either container type (container it then created),
or an Container instance"""
if isinstance(container, basestring):
self.current_container = self._createContainer(container, self.current_container.getParentContainer() or self.main_container, **kwargs)
if not isinstance(self.current_container, self._containers[container]):
self.current_container = self._createContainer(container, self.current_container.getParentContainer() or self.main_container, **kwargs)
else:
self.current_container = self.main_container if container is None else container
assert isinstance(self.current_container, Container)