comparison orpg/mapper/map_msg.py @ 20:072ffc1d466f traipse_dev

2nd attempt. Still untested.
author sirebral
date Sat, 25 Jul 2009 19:23:25 -0500
parents 78407d627cba
children 449a8900f9ac
comparison
equal deleted inserted replaced
19:78407d627cba 20:072ffc1d466f
77 elif name == "fog": 77 elif name == "fog":
78 self.children[name] = fog_msg(self.p_lock) 78 self.children[name] = fog_msg(self.p_lock)
79 else: 79 else:
80 print "Unrecognized tag " + name + " found in map_msg.init_from_dom - skipping" 80 print "Unrecognized tag " + name + " found in map_msg.init_from_dom - skipping"
81 continue 81 continue
82 try: 82 try: self.children[name].init_from_dom(c)
83 self.children[name].init_from_dom(c)
84 except Exception, e: 83 except Exception, e:
85 print "map_msg.init_from_dom() exception: "+str(e) 84 print "map_msg.init_from_dom() exception: "+str(e)
86 continue 85 continue
87 else: 86 else:
88 self.p_lock.release() 87 self.p_lock.release()
89 raise Exception, 88 raise Exception, "Error attempting to initialize a " + self.tagname + " from a non-<" + self.tagname + "/> element"
90 "Error attempting to initialize a " + self.tagname + " from a non-<" + self.tagname + "/> element"
91 self.p_lock.release() 89 self.p_lock.release()
92 90
93 def set_from_dom(self,xml_dom): 91 def set_from_dom(self,xml_dom):
94 self.p_lock.acquire() 92 self.p_lock.acquire()
95 if xml_dom.tagName == self.tagname: 93 if xml_dom.tagName == self.tagname:
102 for k in xml_dom.getAttributeKeys(): 100 for k in xml_dom.getAttributeKeys():
103 self.set_prop(k,xml_dom.getAttribute(k)) 101 self.set_prop(k,xml_dom.getAttribute(k))
104 for c in xml_dom._get_childNodes(): 102 for c in xml_dom._get_childNodes():
105 name = c._get_nodeName() 103 name = c._get_nodeName()
106 if not self.children.has_key(name): 104 if not self.children.has_key(name):
107 if name == "miniatures": 105 if name == "miniatures": self.children[name] = minis_msg(self.p_lock)
108 self.children[name] = minis_msg(self.p_lock) 106 elif name == "grid": self.children[name] = grid_msg(self.p_lock)
109 elif name == "grid": 107 elif name == "bg": self.children[name] = bg_msg(self.p_lock)
110 self.children[name] = grid_msg(self.p_lock) 108 elif name == "whiteboard": self.children[name] = whiteboard_msg(self.p_lock)
111 elif name == "bg": 109 elif name == "fog": self.children[name] = fog_msg(self.p_lock)
112 self.children[name] = bg_msg(self.p_lock)
113 elif name == "whiteboard":
114 self.children[name] = whiteboard_msg(self.p_lock)
115 elif name == "fog":
116 self.children[name] = fog_msg(self.p_lock)
117 else: 110 else:
118 print "Unrecognized tag " + name + " found in map_msg.init_from_dom - skipping" 111 print "Unrecognized tag " + name + " found in map_msg.init_from_dom - skipping"
119 continue 112 continue
120 try: 113 try: self.children[name].set_from_dom(c)
121 self.children[name].set_from_dom(c)
122 except Exception, e: 114 except Exception, e:
123 print "map_msg.set_from_dom() exception: "+str(e) 115 print "map_msg.set_from_dom() exception: "+str(e)
124 continue 116 continue
125 else: 117 else:
126 self.p_lock.release() 118 self.p_lock.release()
127 raise Exception, 119 raise Exception, "Error attempting to set a " + self.tagname + " from a non-<" + self.tagname + "/> element in map"
128 "Error attempting to set a " + self.tagname + " from a non-<" + self.tagname + "/> element in map"
129 self.p_lock.release() 120 self.p_lock.release()
130 121
131 def get_all_xml(self, action="new", output_action=1): 122 def get_all_xml(self, action="new", output_action=1):
132 return map_element_msg_base.get_all_xml(self, action, output_action) 123 return map_element_msg_base.get_all_xml(self, action, output_action)
133 124