Mercurial > traipse_dev
comparison orpg/mapper/base_msg.py @ 122:36919b8a3ef9 alpha
Traipse Alpha 'OpenRPG' {091031-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go.
Traipse also makes it easy for developers to work on code without fear of
sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the
code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the
productivity of the user.
Update Summary (Cleaning up for Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log
Mercurial's hgweb folder is ported to upmana
Happy Halloween!
author | sirebral |
---|---|
date | Sat, 31 Oct 2009 22:07:55 -0500 |
parents | 217fb049bd00 |
children | 8e07c1a2c69b |
comparison
equal
deleted
inserted
replaced
121:496dbf12a6cb | 122:36919b8a3ef9 |
---|---|
28 __version__ = "$Id: base_msg.py,v 1.9 2007/03/09 14:11:55 digitalxero Exp $" | 28 __version__ = "$Id: base_msg.py,v 1.9 2007/03/09 14:11:55 digitalxero Exp $" |
29 | 29 |
30 from threading import RLock | 30 from threading import RLock |
31 from orpg.networking.mplay_client import * | 31 from orpg.networking.mplay_client import * |
32 | 32 |
33 from xml.etree.ElementTree import XML | 33 from xml.etree.ElementTree import XML, fromstring, parse |
34 | 34 |
35 class map_element_msg_base: | 35 class map_element_msg_base: |
36 # This is a base class | 36 # This is a base class |
37 | 37 |
38 def __init__(self,reentrant_lock_object = None): | 38 def __init__(self,reentrant_lock_object = None): |
39 | 39 |
40 if not hasattr(self,"tagname"): | 40 if not self.tagname: |
41 raise Exception, "This is a virtual class that cannot be directly instantiated. Set self.tagname in derived class." | 41 raise Exception, "This is a virtual class that cannot be directly instantiated. Set self.tagname in derived class."; exit() |
42 | 42 |
43 self._props = {} | 43 self._props = {} |
44 # This is a dictionary that holds (value,changed) 2-tuples, indexed by attribute | 44 # This is a dictionary that holds (value,changed) 2-tuples, indexed by attribute |
45 # Avoid manipulating these values directly. Instead, use the provided accessor methods. | 45 # Avoid manipulating these values directly. Instead, use the provided accessor methods. |
46 # If there is not one that suits your needs, please add one to this class and | 46 # If there is not one that suits your needs, please add one to this class and |
200 def _from_dom(self,xml,prop_func): | 200 def _from_dom(self,xml,prop_func): |
201 self.p_lock.acquire() | 201 self.p_lock.acquire() |
202 if xml.tag == self.tagname: | 202 if xml.tag == self.tagname: |
203 if xml.keys(): | 203 if xml.keys(): |
204 for k in xml.keys(): | 204 for k in xml.keys(): |
205 prop_func(k,xml.get(k)) | 205 prop_func(k, xml.get(k)) |
206 else: | 206 else: |
207 self.p_lock.release() | 207 self.p_lock.release() |
208 raise Exception, "Error attempting to modify a " + self.tagname + " from a non-<" + self.tagname + "/> element" | 208 raise Exception, "Error attempting to modify a " + self.tagname + " from a non-<" + self.tagname + "/> element" |
209 self.p_lock.release() | 209 self.p_lock.release() |
210 | 210 |
211 def init_from_dom(self,xml): | 211 def init_from_dom(self, xml): |
212 # xml must be pointing to an empty tag. Override in a derived class for <map/> and other similar tags. | 212 # xml must be pointing to an empty tag. Override in a derived class for <map/> and other similar tags. |
213 self._from_dom(xml,self.init_prop) | 213 self._from_dom(xml,self.init_prop) |
214 | 214 |
215 def set_from_dom(self,xml): | 215 def set_from_dom(self, xml): |
216 # xml must be pointing to an empty tag. Override in a derived class for <map/> and other similar tags | 216 # xml must be pointing to an empty tag. Override in a derived class for <map/> and other similar tags |
217 self._from_dom(xml,self.set_prop) | 217 self._from_dom(xml, self.set_prop) |
218 | 218 |
219 def init_from_xml(self,xmlString): | 219 def init_from_xml(self, tree): |
220 tree = XML(xmlString) | 220 #tree = XML(xmlString) |
221 node_list = tree.findall(self.tagname) | 221 node_list = tree.findall(self.tagname) |
222 if len(node_list) < 1: | 222 if len(node_list) < 1: print "Warning: no <" + self.tagname + "/> elements found in DOM." |
223 print "Warning: no <" + self.tagname + "/> elements found in DOM." | |
224 else: | 223 else: |
225 while len(node_list): | 224 while len(node_list): |
226 self.init_from_dom(node_list.pop()) | 225 self.init_from_dom(node_list.pop()) |
227 | 226 |
228 def set_from_xml(self,xmlString): | 227 def set_from_xml(self, tree): |
229 tree = XML(xmlString) | 228 #tree = XML(xmlString) |
230 node_list = tree.findall(self.tagname) | 229 node_list = tree.findall(self.tagname) |
231 if len(node_list) < 1: | 230 if len(node_list) < 1: print "Warning: no <" + self.tagname + "/> elements found in DOM." |
232 print "Warning: no <" + self.tagname + "/> elements found in DOM." | 231 else: |
233 else: | 232 while len(node_list): self.set_from_dom(node_list.pop()) |
234 while len(node_list): | |
235 self.set_from_dom(node_list.pop()) | |
236 # XML importers end | 233 # XML importers end |
237 ######################################### | 234 ######################################### |