diff options
-rw-r--r-- | sleekxmpp/roster.py | 32 |
1 files changed, 32 insertions, 0 deletions
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, |