diff options
author | Lance Stout <lancestout@gmail.com> | 2011-12-28 10:07:33 -0500 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-12-28 10:16:31 -0500 |
commit | d979b5f2b9cb38bdd145c95526358238449fa067 (patch) | |
tree | 1c34ace495466f73200197cee23b13c2dfebd042 /sleekxmpp/plugins/xep_0128/static.py | |
parent | 1a61bdb302e48d29888ab9b9cc23421bbb3fbead (diff) | |
download | slixmpp-d979b5f2b9cb38bdd145c95526358238449fa067.tar.gz slixmpp-d979b5f2b9cb38bdd145c95526358238449fa067.tar.bz2 slixmpp-d979b5f2b9cb38bdd145c95526358238449fa067.tar.xz slixmpp-d979b5f2b9cb38bdd145c95526358238449fa067.zip |
Add caching support to xep_0030.
New plugin configuration options:
use_cache - Enable caching disco info results. Defaults to True
wrap_results - Always return disco results in an Iq stanza. Defaults
to False
Node handler changes:
Handlers now take four arguments: jid, node, ifrom, data
Most older style handlers will still work, depending on if they
raise a TypeError for incorrect number of arguments. Handlers that
used *args may not work.
New get_info options:
cached - Passing cached=True to get_info() will attempt to load
results from the cache. If nothing is found, a query
will be sent as normal. If set to False, the cache
will be skipped, even if it contains results.
New method:
supports() - Given a JID/node pair and a feature, return True
if the feature is supported, False if not, and
None if there was a timeout. By default, the search
will use the cache.
Diffstat (limited to 'sleekxmpp/plugins/xep_0128/static.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0128/static.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/sleekxmpp/plugins/xep_0128/static.py b/sleekxmpp/plugins/xep_0128/static.py index 493d9370..427011c0 100644 --- a/sleekxmpp/plugins/xep_0128/static.py +++ b/sleekxmpp/plugins/xep_0128/static.py @@ -31,42 +31,43 @@ class StaticExtendedDisco(object): """ self.static = static - def set_extended_info(self, jid, node, data): + def set_extended_info(self, jid, node, ifrom, data): """ Replace the extended identity data for a JID/node combination. The data parameter may provide: data -- Either a single data form, or a list of data forms. """ - self.del_extended_info(jid, node, data) - self.add_extended_info(jid, node, data) + with self.static.lock: + self.del_extended_info(jid, node, ifrom, data) + self.add_extended_info(jid, node, ifrom, data) - def add_extended_info(self, jid, node, data): + def add_extended_info(self, jid, node, ifrom, data): """ Add additional extended identity data for a JID/node combination. The data parameter may provide: data -- Either a single data form, or a list of data forms. """ - self.static.add_node(jid, node) + with self.static.lock: + self.static.add_node(jid, node) - forms = data.get('data', []) - if not isinstance(forms, list): - forms = [forms] + forms = data.get('data', []) + if not isinstance(forms, list): + forms = [forms] - for form in forms: - self.static.nodes[(jid, node)]['info'].append(form) + info = self.static.get_node(jid, node)['info'] + for form in forms: + info.append(form) - def del_extended_info(self, jid, node, data): + def del_extended_info(self, jid, node, ifrom, data): """ Replace the extended identity data for a JID/node combination. The data parameter is not used. """ - if (jid, node) not in self.static.nodes: - return - - info = self.static.nodes[(jid, node)]['info'] - - for form in info['substanza']: - info.xml.remove(form.xml) + with self.static.lock: + if self.static.node_exists(jid, node): + info = self.static.get_node(jid, node)['info'] + for form in info['substanza']: + info.xml.remove(form.xml) |