From 917faecdcbf07b63173b34b708cff5bdf6476d25 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 19 Jul 2012 23:54:18 -0700 Subject: Fix issue of roster data being split across multiple rosters. Resolved by always normalizing JIDs to bare form, regardless of if they are JID objects or strings. Also simplified related code to prefer use of JID objects instead of strings so they don't need to be parsed multiple times. --- sleekxmpp/roster/multi.py | 14 +++++++++----- sleekxmpp/roster/single.py | 14 ++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'sleekxmpp/roster') diff --git a/sleekxmpp/roster/multi.py b/sleekxmpp/roster/multi.py index 9a04aebb..5d070ec8 100644 --- a/sleekxmpp/roster/multi.py +++ b/sleekxmpp/roster/multi.py @@ -94,10 +94,12 @@ class Roster(object): Arguments: key -- Return the roster for this JID. """ - if isinstance(key, JID): - key = key.bare if key is None: - key = self.xmpp.boundjid.bare + key = self.xmpp.boundjid + if not isinstance(key, JID): + key = JID(key) + key = key.bare + if key not in self._rosters: self.add(key) self._rosters[key].auto_authorize = self.auto_authorize @@ -119,8 +121,10 @@ class Roster(object): Arguments: node -- The JID for the new roster node. """ - if isinstance(node, JID): - node = node.bare + if not isinstance(node, JID): + node = JID(node) + + node = node.bare if node not in self._rosters: self._rosters[node] = RosterNode(self.xmpp, node, self.db) diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py index f8c9c781..f080ae8a 100644 --- a/sleekxmpp/roster/single.py +++ b/sleekxmpp/roster/single.py @@ -89,8 +89,11 @@ class RosterNode(object): A new item entry will be created if one does not already exist. """ - if isinstance(key, JID): - key = key.bare + if key is None: + key = JID('') + if not isinstance(key, JID): + key = JID(key) + key = key.bare if key not in self._jids: self.add(key, save=True) return self._jids[key] @@ -101,8 +104,11 @@ class RosterNode(object): To remove an item from the server, use the remove() method. """ - if isinstance(key, JID): - key = key.bare + if key is None: + key = JID('') + if not isinstance(key, JID): + key = JID(key) + key = key.bare if key in self._jids: del self._jids[key] -- cgit v1.2.3