Make the roster backend settable.
This commit is contained in:
parent
de6170a13d
commit
3c871920b1
1 changed files with 32 additions and 0 deletions
|
@ -84,6 +84,17 @@ class Roster(object):
|
||||||
if node not in self._rosters:
|
if node not in self._rosters:
|
||||||
self._rosters[node] = RosterNode(self.xmpp, node, self.db)
|
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):
|
class RosterNode(object):
|
||||||
|
|
||||||
|
@ -148,6 +159,17 @@ class RosterNode(object):
|
||||||
"""Iterate over the roster items."""
|
"""Iterate over the roster items."""
|
||||||
return self._jids.__iter__()
|
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,
|
def add(self, jid, name='', groups=None, afrom=False, ato=False,
|
||||||
pending_in=False, pending_out=False, whitelisted=False,
|
pending_in=False, pending_out=False, whitelisted=False,
|
||||||
save=False):
|
save=False):
|
||||||
|
@ -393,6 +415,16 @@ class RosterItem(object):
|
||||||
self._db_state = {}
|
self._db_state = {}
|
||||||
self.load()
|
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):
|
def load(self):
|
||||||
"""
|
"""
|
||||||
Load the item's state information from an external datastore,
|
Load the item's state information from an external datastore,
|
||||||
|
|
Loading…
Reference in a new issue