From 3c871920b150cc4e3122170a65e16a38aad71c5d Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Wed, 2 Feb 2011 12:05:34 -0500 Subject: Make the roster backend settable. --- sleekxmpp/roster.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sleekxmpp/roster.py b/sleekxmpp/roster.py index 35e739f8..0f55527f 100644 --- a/sleekxmpp/roster.py +++ b/sleekxmpp/roster.py @@ -84,6 +84,17 @@ class Roster(object): if node not in self._rosters: self._rosters[node] = RosterNode(self.xmpp, node, self.db) + def set_backend(self, db=None): + """ + Set the datastore interface object for the roster. + + Arguments: + db -- The new datastore interface. + """ + self.db = db + for node in self._rosters: + self._rosters[node].set_backend(db) + class RosterNode(object): @@ -148,6 +159,17 @@ class RosterNode(object): """Iterate over the roster items.""" return self._jids.__iter__() + def set_backend(self, db=None): + """ + Set the datastore interface object for the roster node. + + Arguments: + db -- The new datastore interface. + """ + self.db = db + for jid in self._jids: + self._jids[jid].set_backend(db) + def add(self, jid, name='', groups=None, afrom=False, ato=False, pending_in=False, pending_out=False, whitelisted=False, save=False): @@ -393,6 +415,16 @@ class RosterItem(object): self._db_state = {} self.load() + def set_backend(self, db=None): + """ + Set the datastore interface object for the roster item. + + Arguments: + db -- The new datastore interface. + """ + self.db = db + self.load() + def load(self): """ Load the item's state information from an external datastore, -- cgit v1.2.3