core: XMLUI now use @property for session_id and submit
This commit is contained in:
parent
3b86e8b106
commit
67df03f7bf
2 changed files with 37 additions and 9 deletions
|
|
@ -277,7 +277,7 @@ class XEP_0050(object):
|
||||||
d = self.requestCommandsList(entity, profile)
|
d = self.requestCommandsList(entity, profile)
|
||||||
|
|
||||||
def sendItems(xmlui):
|
def sendItems(xmlui):
|
||||||
xmlui.setSessionId(session_id) # we need to keep track of the session
|
xmlui.session_id = session_id # we need to keep track of the session
|
||||||
return {'xmlui': xmlui.toXml()}
|
return {'xmlui': xmlui.toXml()}
|
||||||
|
|
||||||
d.addCallback(sendItems)
|
d.addCallback(sendItems)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
from sat.core.i18n import _
|
from sat.core.i18n import _
|
||||||
from logging import debug, info, error, warning
|
from logging import debug, info, error, warning
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom, NotFoundErr
|
||||||
from wokkel import data_form
|
from wokkel import data_form
|
||||||
from twisted.words.xish import domish
|
from twisted.words.xish import domish
|
||||||
from sat.core import exceptions
|
from sat.core import exceptions
|
||||||
|
|
@ -264,10 +264,8 @@ class XMLUI(object):
|
||||||
top_element.setAttribute("type", panel_type)
|
top_element.setAttribute("type", panel_type)
|
||||||
if title:
|
if title:
|
||||||
top_element.setAttribute("title", title)
|
top_element.setAttribute("title", title)
|
||||||
if submit_id:
|
self.submit_id = submit_id
|
||||||
top_element.setAttribute("submit", submit_id)
|
self.session_id = session_id
|
||||||
if session_id is not None:
|
|
||||||
top_element.setAttribute("session_id", session_id)
|
|
||||||
self.parentTabsLayout = None # used only we have 'tabs' layout
|
self.parentTabsLayout = None # used only we have 'tabs' layout
|
||||||
self.currentCategory = None # used only we have 'tabs' layout
|
self.currentCategory = None # used only we have 'tabs' layout
|
||||||
self.currentLayout = None
|
self.currentLayout = None
|
||||||
|
|
@ -276,11 +274,41 @@ class XMLUI(object):
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.doc.unlink()
|
self.doc.unlink()
|
||||||
|
|
||||||
def setSessionId(self, session_id):
|
@property
|
||||||
assert(session_id)
|
def submit_id(self):
|
||||||
top_element = self.doc.documentElement
|
top_element = self.doc.documentElement
|
||||||
top_element.setAttribute("session_id", session_id)
|
value = top_element.getAttribute("submit")
|
||||||
|
return value or None
|
||||||
|
|
||||||
|
@submit_id.setter
|
||||||
|
def submit_id(self, value):
|
||||||
|
top_element = self.doc.documentElement
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
top_element.removeAttribute("submit")
|
||||||
|
except NotFoundErr:
|
||||||
|
pass
|
||||||
|
elif value: # submit_id can be the empty string to bypass form restriction
|
||||||
|
top_element.setAttribute("submit", value)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def session_id(self):
|
||||||
|
top_element = self.doc.documentElement
|
||||||
|
value = top_element.getAttribute("session_id")
|
||||||
|
return value or None
|
||||||
|
|
||||||
|
@session_id.setter
|
||||||
|
def session_id(self, value):
|
||||||
|
top_element = self.doc.documentElement
|
||||||
|
if value is None:
|
||||||
|
try:
|
||||||
|
top_element.removeAttribute("session_id")
|
||||||
|
except NotFoundErr:
|
||||||
|
pass
|
||||||
|
elif value:
|
||||||
|
top_element.setAttribute("session_id", value)
|
||||||
|
else:
|
||||||
|
raise exceptions.DataError("session_id can't be empty")
|
||||||
|
|
||||||
def _createLayout(self, layout, parent=None):
|
def _createLayout(self, layout, parent=None):
|
||||||
"""Create a layout element
|
"""Create a layout element
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue