summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-09-25 20:17:37 -0700
committerLance Stout <lancestout@gmail.com>2012-09-25 20:17:37 -0700
commit94e8b2becf0cb7b81afbf384fb9d0ec61b8abf7d (patch)
treecabb168f3c845c3902a59ef2e12eb6aa8c47164a /sleekxmpp
parenta6ca6701a00337fa500340945d6e6065ba937b40 (diff)
downloadslixmpp-94e8b2becf0cb7b81afbf384fb9d0ec61b8abf7d.tar.gz
slixmpp-94e8b2becf0cb7b81afbf384fb9d0ec61b8abf7d.tar.bz2
slixmpp-94e8b2becf0cb7b81afbf384fb9d0ec61b8abf7d.tar.xz
slixmpp-94e8b2becf0cb7b81afbf384fb9d0ec61b8abf7d.zip
Update RSM iterator to specify where to look to count result sizes.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/plugins/xep_0059/rsm.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/sleekxmpp/plugins/xep_0059/rsm.py b/sleekxmpp/plugins/xep_0059/rsm.py
index 59cfc10b..d73b45bc 100644
--- a/sleekxmpp/plugins/xep_0059/rsm.py
+++ b/sleekxmpp/plugins/xep_0059/rsm.py
@@ -25,11 +25,14 @@ class ResultIterator():
An iterator for Result Set Managment
"""
- def __init__(self, query, interface, amount=10, start=None, reverse=False):
+ def __init__(self, query, interface, results='substanzas', amount=10,
+ start=None, reverse=False):
"""
Arguments:
query -- The template query
interface -- The substanza of the query, for example disco_items
+ results -- The query stanza's interface which provides a
+ countable list of query results.
amount -- The max amounts of items to request per iteration
start -- From which item id to start
reverse -- If True, page backwards through the results
@@ -46,6 +49,7 @@ class ResultIterator():
self.amount = amount
self.start = start
self.interface = interface
+ self.results = results
self.reverse = reverse
self._stop = False
@@ -85,7 +89,7 @@ class ResultIterator():
r[self.interface]['rsm']['first_index']:
count = int(r[self.interface]['rsm']['count'])
first = int(r[self.interface]['rsm']['first_index'])
- num_items = len(r[self.interface]['substanzas'])
+ num_items = len(r[self.interface][self.results])
if first + num_items == count:
self._stop = True
@@ -123,7 +127,7 @@ class XEP_0059(BasePlugin):
def session_bind(self, jid):
self.xmpp['xep_0030'].add_feature(Set.namespace)
- def iterate(self, stanza, interface):
+ def iterate(self, stanza, interface, results='substanzas'):
"""
Create a new result set iterator for a given stanza query.
@@ -135,5 +139,7 @@ class XEP_0059(BasePlugin):
result set management stanza should be
appended. For example, for disco#items queries
the interface 'disco_items' should be used.
+ results -- The name of the interface containing the
+ query results (typically just 'substanzas').
"""
- return ResultIterator(stanza, interface)
+ return ResultIterator(stanza, interface, results)