From 3dbd496de8b6d358b657eada91acc6b71455ffbf Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Sat, 23 Jan 2010 01:08:21 -0800 Subject: fixed presence['type'] w/ show value bug and added test to prove --- sleekxmpp/stanza/presence.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sleekxmpp') diff --git a/sleekxmpp/stanza/presence.py b/sleekxmpp/stanza/presence.py index 6a8247c5..2bf767d4 100644 --- a/sleekxmpp/stanza/presence.py +++ b/sleekxmpp/stanza/presence.py @@ -15,18 +15,18 @@ class Presence(RootStanza): return self.xml.find("{%s}show" % self.namespace) def setType(self, value): + show = self.getShowElement() if value in self.types: - show = self.getShowElement() - if value in self.types: - if show is not None: - self.xml.remove(show) - if value == 'available': - value = '' - self._setAttr('type', value) - elif value in self.showtypes: - if show is None: - show = ET.Element("{%s}show" % self.namespace) - show.text = value + if show is not None: + self.xml.remove(show) + if value == 'available': + value = '' + self._setAttr('type', value) + elif value in self.showtypes: + if show is None: + show = ET.Element("{%s}show" % self.namespace) + self.xml.append(show) + show.text = value return self def setPriority(self, value): -- cgit v1.2.3