예제 #1
0
 def edit_one(session, element, attrib, value):
     if attrib == "room":
         if value == "":
             element.room = None
         else:
             my_room = Room.get_one(session, value)
             if isinstance(my_room, Room):
                 element.room = my_room
             else:
                 return User.ERROR_VALUE_NOT_VALID
     elif attrib == "receive_room":
         if value == "":
             element.receive_room = None
         else:
             my_room = Room.get_one(session, value)
             if isinstance(my_room, Room):
                 element.receive_room = my_room
             else:
                 return User.ERROR_VALUE_NOT_VALID
     elif attrib == "admin":
         if value == "True":
             element.admin = True
         else:
             element.admin = False
     else:
         return Role.edit_one(element, attrib, value)
예제 #2
0
 def import_one(session, input, element=None, name=None):
     if element == None:
         element = Node()
     tree = ElementTree.fromstring(input)
     if tree.tag == "node":
         element = Role.import_one(tree, element, name)
         room = tree.findtext("room")
         if room != None:
             element = Node.edit_one(session, element, "room", room)
             if not isinstance(element, Node):
                 return element
         title = tree.findtext("title")
         if title != None:
             Node.edit_one(session, element, "title", title)
         type = tree.findtext("type")
         if type != None:
             Node.edit_one(session, element, "type", type)
         input = tree.findtext("input")
         if input != None:
             Node.edit_one(session, element, "input", input)
         output = tree.findtext("output")
         if output != None:
             Node.edit_one(session, element, "output", output)
         return element
     else:
         return Node.ERROR_TAG_NOT_VALID
예제 #3
0
 def edit_one(session, element, attrib, value):
     if attrib == "master":
         if value == "True":
             element.master = True
         else:
             element.master = False
     else:
         return Role.edit_one(element, attrib, value)
예제 #4
0
 def import_one(session, input, element=None, name=None):
     if element == None:
         element = Monitor()
     tree = ElementTree.fromstring(input)
     if tree.tag == "monitor":
         element = Role.import_one(tree, element, name)
         return element
     else:
         return Monitor.ERROR_TAG_NOT_VALID
예제 #5
0
 def export_one(element, attribs):
     tree = ElementTree.Element("backend")
     tree = Role.export_one(tree, element, attribs)
     if "master" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "master")
         if element.master != None:
             if element.master == True:
                 attrib.text = "True"
             else:
                 attrib.text = "False"
     return ElementTree.tostring(tree, "UTF-8")
예제 #6
0
 def import_one(session, input, element=None, name=None):
     if element == None:
         element = Backend()
     tree = ElementTree.fromstring(input)
     if tree.tag == "backend":
         element = Role.import_one(tree, element, name)
         master = tree.findtext("master")
         if master != None:
             Backend.edit_one(session, element, "master", master)
         return element
     else:
         return Backend.ERROR_TAG_NOT_VALID
예제 #7
0
 def export_one(element, attribs):
     tree = ElementTree.Element("user")
     tree = Role.export_one(tree, element, attribs)
     if "room" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "room")
         if element.room != None:
             attrib.text = element.room.name
     if "receive_room" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "receive_room")
         if element.receive_room != None:
             attrib.text = element.receive_room.name
     if "admin" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "admin")
         if element.admin != None:
             if element.admin == True:
                 attrib.text = "True"
             else:
                 attrib.text = "False"
     return ElementTree.tostring(tree, "UTF-8")
예제 #8
0
 def export_one(element, attribs):
     tree = ElementTree.Element("node")
     tree = Role.export_one(tree, element, attribs)
     if "room" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "room")
         if element.room != None:
             attrib.text = element.room.name
     if "title" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "title")
         attrib.text = element.title
     if "type" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "type")
         attrib.text = element.type
     if "input" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "input")
         attrib.text = element.input
     if "output" in attribs or attribs == "all":
         attrib = ElementTree.SubElement(tree, "output")
         attrib.text = element.output
     return ElementTree.tostring(tree, "UTF-8")
예제 #9
0
 def edit_one(session, element, attrib, value):
     if attrib == "room":
         if value == "":
             element.room = None
         else:
             my_room = Room.get_one(session, value)
             if isinstance(my_room, Room):
                 element.room = my_room
             else:
                 return Node.ERROR_VALUE_NOT_VALID
     elif attrib == "title":
         element.title = value
     elif attrib == "tyoe":
         element.type = value
     elif attrib == "input":
         element.input = value
     elif attrib == "output":
         element.output = value
     else:
         return Role.edit_one(element, attrib, value)
예제 #10
0
 def import_one(session, input, element=None, name=None):
     if element == None:
         element = User()
     tree = ElementTree.fromstring(input)
     if tree.tag == "user":
         element = Role.import_one(tree, element, name)
         room = tree.findtext("room")
         if room != None:
             element = User.edit_one(session, element, "room", room)
             if not isinstance(element, User):
                 return element
         receive_room = tree.findtext("receive_room")
         if receive_room != None:
             element = User.edit_one(session, element, "receive_room", receive_room)
             if not isinstance(element, User):
                 return element
         admin = tree.findtext("admin")
         if admin != None:
             User.edit_one(session, element, "admin", admin)
         return element
     else:
         return User.ERROR_TAG_NOT_VALID
예제 #11
0
 def edit_one(session, element, attrib, value):
     return Role.edit_one(element, attrib, value)
예제 #12
0
 def export_one(element, attribs):
     tree = ElementTree.Element("monitor")
     tree = Role.export_one(tree, element, attribs)
     return ElementTree.tostring(tree, "UTF-8")