summaryrefslogtreecommitdiff
path: root/sleekxmpp/roster
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-03-05 11:28:10 -0800
committerLance Stout <lancestout@gmail.com>2012-03-05 11:28:10 -0800
commitfdfe2cd64f36ea467b7cf469b1e078bd2eeb34f5 (patch)
tree7014cabeeac2309679f98d922e8f1df2d0d33b7e /sleekxmpp/roster
parent7b51c6f5ccfbd7937184b49ddbfeae927c8a3248 (diff)
downloadslixmpp-fdfe2cd64f36ea467b7cf469b1e078bd2eeb34f5.tar.gz
slixmpp-fdfe2cd64f36ea467b7cf469b1e078bd2eeb34f5.tar.bz2
slixmpp-fdfe2cd64f36ea467b7cf469b1e078bd2eeb34f5.tar.xz
slixmpp-fdfe2cd64f36ea467b7cf469b1e078bd2eeb34f5.zip
Propagate save option when setting a roster backend.
Diffstat (limited to 'sleekxmpp/roster')
-rw-r--r--sleekxmpp/roster/multi.py6
-rw-r--r--sleekxmpp/roster/single.py6
2 files changed, 8 insertions, 4 deletions
diff --git a/sleekxmpp/roster/multi.py b/sleekxmpp/roster/multi.py
index 84577a9d..6a60778b 100644
--- a/sleekxmpp/roster/multi.py
+++ b/sleekxmpp/roster/multi.py
@@ -95,19 +95,21 @@ class Roster(object):
if node not in self._rosters:
self._rosters[node] = RosterNode(self.xmpp, node, self.db)
- def set_backend(self, db=None):
+ def set_backend(self, db=None, save=True):
"""
Set the datastore interface object for the roster.
Arguments:
db -- The new datastore interface.
+ save -- If True, save the existing state to the new
+ backend datastore. Defaults to True.
"""
self.db = db
existing_entries = set(self._rosters)
new_entries = set(self.db.entries(None, {}))
for node in existing_entries:
- self._rosters[node].set_backend(db)
+ self._rosters[node].set_backend(db, save)
for node in new_entries - existing_entries:
self.add(node)
diff --git a/sleekxmpp/roster/single.py b/sleekxmpp/roster/single.py
index 611f8944..159eb07d 100644
--- a/sleekxmpp/roster/single.py
+++ b/sleekxmpp/roster/single.py
@@ -101,19 +101,21 @@ class RosterNode(object):
"""Iterate over the roster items."""
return self._jids.__iter__()
- def set_backend(self, db=None):
+ def set_backend(self, db=None, save=True):
"""
Set the datastore interface object for the roster node.
Arguments:
db -- The new datastore interface.
+ save -- If True, save the existing state to the new
+ backend datastore. Defaults to True.
"""
self.db = db
existing_entries = set(self._jids)
new_entries = set(self.db.entries(self.jid, {}))
for jid in existing_entries:
- self._jids[jid].set_backend(db)
+ self._jids[jid].set_backend(db, save)
for jid in new_entries - existing_entries:
self.add(jid)