From 5af2f62c049825a5f606b7041fa7e6f918d8486c Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Sun, 8 Jul 2012 22:06:08 +0200 Subject: Make sure that the last RSM stanza is returned from the iterator --- sleekxmpp/plugins/xep_0059/rsm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0059') diff --git a/sleekxmpp/plugins/xep_0059/rsm.py b/sleekxmpp/plugins/xep_0059/rsm.py index 9335ed22..d4218202 100644 --- a/sleekxmpp/plugins/xep_0059/rsm.py +++ b/sleekxmpp/plugins/xep_0059/rsm.py @@ -47,6 +47,7 @@ class ResultIterator(): self.start = start self.interface = interface self.reverse = reverse + self._stop = False def __iter__(self): return self @@ -62,6 +63,8 @@ class ResultIterator(): results will be the items before the current page of items. """ + if self._stop: + raise StopIteration self.query[self.interface]['rsm']['before'] = self.reverse self.query['id'] = self.query.stream.new_id() self.query[self.interface]['rsm']['max'] = str(self.amount) @@ -84,7 +87,7 @@ class ResultIterator(): first = int(r[self.interface]['rsm']['first_index']) num_items = len(r[self.interface]['substanzas']) if first + num_items == count: - raise StopIteration + self._stop = True if self.reverse: self.start = r[self.interface]['rsm']['first'] -- cgit v1.2.3 From e8a3e92ceb17d57ae95efd2a3fe7ed82c6ce2a2f Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 10 Jul 2012 01:37:44 -0700 Subject: Update plugins to use session_bind handler for disco, and use plugin_end --- sleekxmpp/plugins/xep_0059/rsm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sleekxmpp/plugins/xep_0059') diff --git a/sleekxmpp/plugins/xep_0059/rsm.py b/sleekxmpp/plugins/xep_0059/rsm.py index d4218202..59cfc10b 100644 --- a/sleekxmpp/plugins/xep_0059/rsm.py +++ b/sleekxmpp/plugins/xep_0059/rsm.py @@ -114,10 +114,15 @@ class XEP_0059(BasePlugin): """ Start the XEP-0059 plugin. """ - self.xmpp['xep_0030'].add_feature(Set.namespace) register_stanza_plugin(self.xmpp['xep_0030'].stanza.DiscoItems, self.stanza.Set) + def plugin_end(self): + self.xmpp['xep_0030'].del_feature(feature=Set.namespace) + + def session_bind(self, jid): + self.xmpp['xep_0030'].add_feature(Set.namespace) + def iterate(self, stanza, interface): """ Create a new result set iterator for a given stanza query. -- cgit v1.2.3