diff options
author | Lance Stout <lancestout@gmail.com> | 2011-02-02 12:05:34 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-02-02 12:05:34 -0500 |
commit | 3c871920b150cc4e3122170a65e16a38aad71c5d (patch) | |
tree | 73b51b4ca4b31757534170115571c3fe225c4717 /sleekxmpp | |
parent | de6170a13de2dbb3cbcfbf4a74b749f20b0cf061 (diff) | |
download | slixmpp-3c871920b150cc4e3122170a65e16a38aad71c5d.tar.gz slixmpp-3c871920b150cc4e3122170a65e16a38aad71c5d.tar.bz2 slixmpp-3c871920b150cc4e3122170a65e16a38aad71c5d.tar.xz slixmpp-3c871920b150cc4e3122170a65e16a38aad71c5d.zip |
Make the roster backend settable.
Diffstat (limited to 'sleekxmpp')
-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, |