From 7b51c6f5ccfbd7937184b49ddbfeae927c8a3248 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Mon, 5 Mar 2012 11:12:13 -0800 Subject: Save existing roster content when setting a new backend. --- sleekxmpp/roster/item.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sleekxmpp/roster') diff --git a/sleekxmpp/roster/item.py b/sleekxmpp/roster/item.py index bd7bbbde..eb2f64b3 100644 --- a/sleekxmpp/roster/item.py +++ b/sleekxmpp/roster/item.py @@ -137,14 +137,18 @@ class RosterItem(object): self._db_state = {} self.load() - def set_backend(self, db=None): + def set_backend(self, db=None, save=True): """ Set the datastore interface object for the roster item. Arguments: - db -- The new datastore interface. + db -- The new datastore interface. + save -- If True, save the existing state to the new + backend datastore. Defaults to True. """ self.db = db + if save: + self.save() self.load() def load(self): -- cgit v1.2.3