summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza/message.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-17 21:38:22 -0400
committerLance Stout <lancestout@gmail.com>2010-10-17 22:04:42 -0400
commit4375ac7d8b9e62f34a4d3754a90b3538d5e978a3 (patch)
treec7da6dddc72ecd299f16d5dd82a4d81f8b0146fa /sleekxmpp/stanza/message.py
parentfaec86b3be38756510fb3534c7615db75ecd53b7 (diff)
downloadslixmpp-4375ac7d8b9e62f34a4d3754a90b3538d5e978a3.tar.gz
slixmpp-4375ac7d8b9e62f34a4d3754a90b3538d5e978a3.tar.bz2
slixmpp-4375ac7d8b9e62f34a4d3754a90b3538d5e978a3.tar.xz
slixmpp-4375ac7d8b9e62f34a4d3754a90b3538d5e978a3.zip
Underscore names by default.
Stanza objects now accept the use of underscored names. The CamelCase versions are still available for backwards compatibility, but are discouraged. The property stanza.values now maps to the old getStanzaValues and setStanzaValues, in addition to _set_stanza_values and _get_stanza_values.
Diffstat (limited to 'sleekxmpp/stanza/message.py')
-rw-r--r--sleekxmpp/stanza/message.py60
1 files changed, 41 insertions, 19 deletions
diff --git a/sleekxmpp/stanza/message.py b/sleekxmpp/stanza/message.py
index 560e1d47..66c74d8a 100644
--- a/sleekxmpp/stanza/message.py
+++ b/sleekxmpp/stanza/message.py
@@ -8,7 +8,7 @@
from sleekxmpp.stanza import Error
from sleekxmpp.stanza.rootstanza import RootStanza
-from sleekxmpp.xmlstream.stanzabase import StanzaBase, ET
+from sleekxmpp.xmlstream import StanzaBase, ET
class Message(RootStanza):
@@ -42,16 +42,17 @@ class Message(RootStanza):
types -- May be one of: normal, chat, headline, groupchat, or error.
Methods:
- chat -- Set the message type to 'chat'.
- normal -- Set the message type to 'normal'.
- reply -- Overrides StanzaBase.reply
- getType -- Overrides StanzaBase interface
- getMucroom -- Return the name of the MUC room of the message.
- setMucroom -- Dummy method to prevent assignment.
- delMucroom -- Dummy method to prevent deletion.
- getMucnick -- Return the MUC nickname of the message's sender.
- setMucnick -- Dummy method to prevent assignment.
- delMucnick -- Dummy method to prevent deletion.
+ setup -- Overrides StanzaBase.setup.
+ chat -- Set the message type to 'chat'.
+ normal -- Set the message type to 'normal'.
+ reply -- Overrides StanzaBase.reply
+ get_type -- Overrides StanzaBase interface
+ get_mucroom -- Return the name of the MUC room of the message.
+ set_mucroom -- Dummy method to prevent assignment.
+ del_mucroom -- Dummy method to prevent deletion.
+ get_mucnick -- Return the MUC nickname of the message's sender.
+ set_mucnick -- Dummy method to prevent assignment.
+ del_mucnick -- Dummy method to prevent deletion.
"""
namespace = 'jabber:client'
@@ -62,7 +63,28 @@ class Message(RootStanza):
plugin_attrib = name
types = set((None, 'normal', 'chat', 'headline', 'error', 'groupchat'))
- def getType(self):
+ def setup(self, xml=None):
+ """
+ Populate the stanza object using an optional XML object.
+
+ Overrides StanzaBase.setup.
+
+ Arguments:
+ xml -- Use an existing XML object for the stanza's values.
+ """
+ # To comply with PEP8, method names now use underscores.
+ # Deprecated method names are re-mapped for backwards compatibility.
+ self.getType = self.get_type
+ self.getMucroom = self.get_mucroom
+ self.setMucroom = self.set_mucroom
+ self.delMucroom = self.del_mucroom
+ self.getMucnick = self.get_mucnick
+ self.setMucnick = self.set_mucnick
+ self.delMucnick = self.del_mucnick
+
+ return StanzaBase.setup(self, xml)
+
+ def get_type(self):
"""
Return the message type.
@@ -70,7 +92,7 @@ class Message(RootStanza):
Returns 'normal' if no type attribute is present.
"""
- return self._getAttr('type', 'normal')
+ return self._get_attr('type', 'normal')
def chat(self):
"""Set the message type to 'chat'."""
@@ -104,7 +126,7 @@ class Message(RootStanza):
self['body'] = body
return self
- def getMucroom(self):
+ def get_mucroom(self):
"""
Return the name of the MUC room where the message originated.
@@ -115,7 +137,7 @@ class Message(RootStanza):
else:
return ''
- def getMucnick(self):
+ def get_mucnick(self):
"""
Return the nickname of the MUC user that sent the message.
@@ -126,18 +148,18 @@ class Message(RootStanza):
else:
return ''
- def setMucroom(self, value):
+ def set_mucroom(self, value):
"""Dummy method to prevent modification."""
pass
- def delMucroom(self):
+ def del_mucroom(self):
"""Dummy method to prevent deletion."""
pass
- def setMucnick(self, value):
+ def set_mucnick(self, value):
"""Dummy method to prevent modification."""
pass
- def delMucnick(self):
+ def del_mucnick(self):
"""Dummy method to prevent deletion."""
pass