summaryrefslogtreecommitdiff
path: root/sleekxmpp/stanza
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-02-14 13:49:43 -0500
committerLance Stout <lancestout@gmail.com>2011-02-14 13:49:43 -0500
commit75584d7ad74b284d30164cde0b5efec2c845d207 (patch)
treee171f1dcd9cd46c5be823cb19233311b49938f70 /sleekxmpp/stanza
parente0f9025e7c6fe51243222aeb684b94eda1a2be5f (diff)
downloadslixmpp-75584d7ad74b284d30164cde0b5efec2c845d207.tar.gz
slixmpp-75584d7ad74b284d30164cde0b5efec2c845d207.tar.bz2
slixmpp-75584d7ad74b284d30164cde0b5efec2c845d207.tar.xz
slixmpp-75584d7ad74b284d30164cde0b5efec2c845d207.zip
Remap old method names in a better way.
This should prevent some reference cycles that will cause garbage collection issues.
Diffstat (limited to 'sleekxmpp/stanza')
-rw-r--r--sleekxmpp/stanza/error.py19
-rw-r--r--sleekxmpp/stanza/htmlim.py23
-rw-r--r--sleekxmpp/stanza/iq.py15
-rw-r--r--sleekxmpp/stanza/message.py32
-rw-r--r--sleekxmpp/stanza/nick.py23
-rw-r--r--sleekxmpp/stanza/presence.py30
-rw-r--r--sleekxmpp/stanza/roster.py23
7 files changed, 57 insertions, 108 deletions
diff --git a/sleekxmpp/stanza/error.py b/sleekxmpp/stanza/error.py
index 09229bc6..5d1ce50d 100644
--- a/sleekxmpp/stanza/error.py
+++ b/sleekxmpp/stanza/error.py
@@ -77,15 +77,6 @@ class Error(ElementBase):
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.getCondition = self.get_condition
- self.setCondition = self.set_condition
- self.delCondition = self.del_condition
- self.getText = self.get_text
- self.setText = self.set_text
- self.delText = self.del_text
-
if ElementBase.setup(self, xml):
#If we had to generate XML then set default values.
self['type'] = 'cancel'
@@ -139,3 +130,13 @@ class Error(ElementBase):
"""Remove the <text> element."""
self._del_sub('{%s}text' % self.condition_ns)
return self
+
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Error.getCondition = Error.get_condition
+Error.setCondition = Error.set_condition
+Error.delCondition = Error.del_condition
+Error.getText = Error.get_text
+Error.setText = Error.set_text
+Error.delText = Error.del_text
diff --git a/sleekxmpp/stanza/htmlim.py b/sleekxmpp/stanza/htmlim.py
index 45868287..d21a74e1 100644
--- a/sleekxmpp/stanza/htmlim.py
+++ b/sleekxmpp/stanza/htmlim.py
@@ -46,23 +46,6 @@ class HTMLIM(ElementBase):
interfaces = set(('body',))
plugin_attrib = name
- 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.setBody = self.set_body
- self.getBody = self.get_body
- self.delBody = self.del_body
-
- return ElementBase.setup(self, xml)
-
def set_body(self, html):
"""
Set the contents of the HTML body.
@@ -95,3 +78,9 @@ class HTMLIM(ElementBase):
register_stanza_plugin(Message, HTMLIM)
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+HTMLIM.setBody = HTMLIM.set_body
+HTMLIM.getBody = HTMLIM.get_body
+HTMLIM.delBody = HTMLIM.del_body
diff --git a/sleekxmpp/stanza/iq.py b/sleekxmpp/stanza/iq.py
index 330df6c2..2bfbc7b1 100644
--- a/sleekxmpp/stanza/iq.py
+++ b/sleekxmpp/stanza/iq.py
@@ -75,13 +75,6 @@ class Iq(RootStanza):
Overrides StanzaBase.__init__.
"""
StanzaBase.__init__(self, *args, **kwargs)
- # To comply with PEP8, method names now use underscores.
- # Deprecated method names are re-mapped for backwards compatibility.
- self.setPayload = self.set_payload
- self.getQuery = self.get_query
- self.setQuery = self.set_query
- self.delQuery = self.del_query
-
if self['id'] == '':
if self.stream is not None:
self['id'] = self.stream.getNewId()
@@ -229,3 +222,11 @@ class Iq(RootStanza):
else:
StanzaBase._set_stanza_values(self, values)
return self
+
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Iq.setPayload = Iq.set_payload
+Iq.getQuery = Iq.get_query
+Iq.setQuery = Iq.set_query
+Iq.delQuery = Iq.del_query
diff --git a/sleekxmpp/stanza/message.py b/sleekxmpp/stanza/message.py
index 6f0cf212..cb3d344c 100644
--- a/sleekxmpp/stanza/message.py
+++ b/sleekxmpp/stanza/message.py
@@ -63,27 +63,6 @@ class Message(RootStanza):
plugin_attrib = name
types = set((None, 'normal', 'chat', 'headline', 'error', 'groupchat'))
- 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.
@@ -165,3 +144,14 @@ class Message(RootStanza):
def del_mucnick(self):
"""Dummy method to prevent deletion."""
pass
+
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Message.getType = Message.get_type
+Message.getMucroom = Message.get_mucroom
+Message.setMucroom = Message.set_mucroom
+Message.delMucroom = Message.del_mucroom
+Message.getMucnick = Message.get_mucnick
+Message.setMucnick = Message.set_mucnick
+Message.delMucnick = Message.del_mucnick
diff --git a/sleekxmpp/stanza/nick.py b/sleekxmpp/stanza/nick.py
index dce41d14..1e23d34f 100644
--- a/sleekxmpp/stanza/nick.py
+++ b/sleekxmpp/stanza/nick.py
@@ -49,23 +49,6 @@ class Nick(ElementBase):
plugin_attrib = name
interfaces = set(('nick',))
- 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.setNick = self.set_nick
- self.getNick = self.get_nick
- self.delNick = self.del_nick
-
- return ElementBase.setup(self, xml)
-
def set_nick(self, nick):
"""
Add a <nick> element with the given nickname.
@@ -87,3 +70,9 @@ class Nick(ElementBase):
register_stanza_plugin(Message, Nick)
register_stanza_plugin(Presence, Nick)
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Nick.setNick = Nick.set_nick
+Nick.getNick = Nick.get_nick
+Nick.delNick = Nick.del_nick
diff --git a/sleekxmpp/stanza/presence.py b/sleekxmpp/stanza/presence.py
index 60dddf64..c8706233 100644
--- a/sleekxmpp/stanza/presence.py
+++ b/sleekxmpp/stanza/presence.py
@@ -72,26 +72,6 @@ class Presence(RootStanza):
'subscribed', 'unsubscribe', 'unsubscribed'))
showtypes = set(('dnd', 'chat', 'xa', 'away'))
- def setup(self, xml=None):
- """
- Populate the stanza object using an optional XML object.
-
- Overrides ElementBase.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.setShow = self.set_show
- self.getType = self.get_type
- self.setType = self.set_type
- self.delType = self.get_type
- self.getPriority = self.get_priority
- self.setPriority = self.set_priority
-
- return StanzaBase.setup(self, xml)
-
def exception(self, e):
"""
Override exception passback for presence.
@@ -188,3 +168,13 @@ class Presence(RootStanza):
elif self['type'] == 'subscribe':
self['type'] = 'subscribed'
return StanzaBase.reply(self, clear)
+
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Presence.setShow = Presence.set_show
+Presence.getType = Presence.get_type
+Presence.setType = Presence.set_type
+Presence.delType = Presence.get_type
+Presence.getPriority = Presence.get_priority
+Presence.setPriority = Presence.set_priority
diff --git a/sleekxmpp/stanza/roster.py b/sleekxmpp/stanza/roster.py
index 8f154a22..afe75516 100644
--- a/sleekxmpp/stanza/roster.py
+++ b/sleekxmpp/stanza/roster.py
@@ -38,23 +38,6 @@ class Roster(ElementBase):
plugin_attrib = 'roster'
interfaces = set(('items',))
- 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.setItems = self.set_items
- self.getItems = self.get_items
- self.delItems = self.del_items
-
- return ElementBase.setup(self, xml)
-
def set_items(self, items):
"""
Set the roster entries in the <roster> stanza.
@@ -123,3 +106,9 @@ class Roster(ElementBase):
register_stanza_plugin(Iq, Roster)
+
+# To comply with PEP8, method names now use underscores.
+# Deprecated method names are re-mapped for backwards compatibility.
+Roster.setItems = Roster.set_items
+Roster.getItems = Roster.get_items
+Roster.delItems = Roster.del_items