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
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
from sat.core.i18n import _
|
||||
from logging import debug, info, error, warning
|
||||
from xml.dom import minidom
|
||||
from xml.dom import minidom, NotFoundErr
|
||||
from wokkel import data_form
|
||||
from twisted.words.xish import domish
|
||||
from sat.core import exceptions
|
||||
|
|
@ -264,10 +264,8 @@ class XMLUI(object):
|
|||
top_element.setAttribute("type", panel_type)
|
||||
if title:
|
||||
top_element.setAttribute("title", title)
|
||||
if submit_id:
|
||||
top_element.setAttribute("submit", submit_id)
|
||||
if session_id is not None:
|
||||
top_element.setAttribute("session_id", session_id)
|
||||
self.submit_id = submit_id
|
||||
self.session_id = session_id
|
||||
self.parentTabsLayout = None # used only we have 'tabs' layout
|
||||
self.currentCategory = None # used only we have 'tabs' layout
|
||||
self.currentLayout = None
|
||||
|
|
@ -276,11 +274,41 @@ class XMLUI(object):
|
|||
def __del__(self):
|
||||
self.doc.unlink()
|
||||
|
||||
def setSessionId(self, session_id):
|
||||
assert(session_id)
|
||||
@property
|
||||
def submit_id(self):
|
||||
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):
|
||||
"""Create a layout element
|
||||
|
|
|
|||
Loading…
Reference in a new issue