Mercurial > traipse_dev
diff orpg/chat/chat_msg.py @ 71:449a8900f9ac ornery-dev
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author | sirebral |
---|---|
date | Thu, 20 Aug 2009 03:00:39 -0500 |
parents | c54768cffbd4 |
children | 37d26a98883f |
line wrap: on
line diff
--- a/orpg/chat/chat_msg.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/chat/chat_msg.py Thu Aug 20 03:00:39 2009 -0500 @@ -29,9 +29,10 @@ __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" -#import orpg.orpg_xml from orpg.orpgCore import * -from chat_version import CHAT_VERSION +from chat_version import CHAT_VERSION +from orpg.tools.orpg_log import logger +from orpg.tools.decorators import debugging CHAT_MESSAGE = 1 WHISPER_MESSAGE = 2 @@ -40,22 +41,24 @@ SYSTEM_MESSAGE = 5 WHISPER_EMOTE_MESSAGE = 6 -class chat_msg: +class chat_msg: + @debugging def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): - self.xml = component.get('xml') self.chat_dom = None self.takexml(xml_text) - + + @debugging def __del__(self): if self.chat_dom: self.chat_dom.unlink() - + + @debugging def toxml(self): - return self.xml.toxml(self.chat_dom) - + return component.get('xml').toxml(self.chat_dom) + + @debugging def takexml(self,xml_text): - #self.xml = component.get('xml') - xml_dom = self.xml.parseXml(xml_text) + xml_dom = component.get('xml').parseXml(xml_text) node_list = xml_dom.getElementsByTagName("chat") if len(node_list) < 1: print "Warning: no <chat/> elements found in DOM." @@ -63,32 +66,40 @@ if len(node_list) > 1: print "Found more than one instance of <" + self.tagname + "/>. Taking first one" self.takedom(node_list[0]) - + + @debugging def takedom(self,xml_dom): if self.chat_dom: self.text_node = None self.chat_dom.unlink() self.chat_dom = xml_dom - self.text_node = self.xml.safe_get_text_node(self.chat_dom) - + self.text_node = component.get('xml').safe_get_text_node(self.chat_dom) + + @debugging def set_text(self,text): - text = self.xml.strip_text(text) + text = component.get('xml').strip_text(text) self.text_node._set_nodeValue(text) - + + @debugging def set_type(self,type): self.chat_dom.setAttribute("type",str(type)) - + + @debugging def get_type(self): return int(self.chat_dom.getAttribute("type")) - + + @debugging def set_alias(self,alias): self.chat_dom.setAttribute("alias",alias) - + + @debugging def get_alias(self): return self.chat_dom.getAttribute("alias") - + + @debugging def get_text(self): return self.text_node._get_nodeValue() - + + @debugging def get_version(self): return self.chat_dom.getAttribute("version")