XEP-0059: Result Set Management#

class slixmpp.plugins.xep_0059.XEP_0059(xmpp, config=None)[source]#

XEP-0059: Result Set Management

iterate(stanza, interface, results='substanzas', amount=10, reverse=False, recv_interface=None, pre_cb=None, post_cb=None, iq_options=None)[source]#

Create a new result set iterator for a given stanza query.

  • stanza (Iq) – A stanza object to serve as a template for queries made each iteration. For example, a basic disco#items query.

  • interface (str) – The name of the substanza to which the result set management stanza should be appended in the query stanza. For example, for disco#items queries the interface ‘disco_items’ should be used.

  • recv_interface (Optional[str]) – The name of the substanza from which the result set management stanza should be read in the result stanza. If unspecified, it will be set to the same value as the interface parameter.

  • pre_cb (Optional[Callable[[Iq], None]]) – Callback to run before sending each stanza e.g. setting the MAM queryid and starting a stanza collector.

  • post_cb (Optional[Callable[[Iq], None]]) – Callback to run after receiving each stanza e.g. stopping a MAM stanza collector in order to gather results.

  • results (str) – The name of the interface containing the query results (typically just ‘substanzas’).

  • iq_options (Optional[Dict[str, Any]]) – Optional dict of parameters for Iq.send

Return type


class slixmpp.plugins.xep_0059.ResultIterator(query, interface, results='substanzas', amount=10, start=None, reverse=False, recv_interface=None, pre_cb=None, post_cb=None, iq_options=None)[source]#

An iterator for Result Set Management


q = Iq()
q['to'] = 'pubsub.example.com'
q['disco_items']['node'] = 'blog'
async for i in ResultIterator(q, 'disco_items', '10'):
query: slixmpp.stanza.iq.Iq#

Template for the RSM query

amount: int#

Amount of elements to retrieve for each page

start: Optional[str]#

From which item id to start

iq_options: Dict[str, Any]#

Optional dict of Iq options (timeout, etc…) for Iq.send()

interface: str#

Substanza of the query to send, e.g. “disco_items”

pre_cb: Optional[Callable[[slixmpp.stanza.iq.Iq], None]]#

Callback to run before sending the stanza

post_cb: Optional[Callable[[slixmpp.stanza.iq.Iq], None]]#

Callback to run after receiving the reply

results: str#

Stanza interface on the query results providing the retrieved elements (used to count them)

reverse: bool#

If True, page backwards through the results

async next()[source]#

Return the next page of results from a query.

Note: If using backwards paging, then the next page of

results will be the items before the current page of items.

Return type


Stanza elements#

class slixmpp.plugins.xep_0059.stanza.Set(xml=None, parent=None)[source]#

XEP-0059 (Result Set Management) can be used to manage the results of queries. For example, limiting the number of items per response or starting at certain positions.

Example set stanzas:

<iq type="get">
  <query xmlns="http://jabber.org/protocol/disco#items">
    <set xmlns="http://jabber.org/protocol/rsm">

<iq type="result">
  <query xmlns="http://jabber.org/protocol/disco#items">
    <item jid="conference.example.com" />
    <item jid="pubsub.example.com" />
    <set xmlns="http://jabber.org/protocol/rsm">

Stanza Interface:

first_index -- The index attribute of <first>
after       -- The id defining from which item to start
before      -- The id defining from which item to
               start when browsing backwards
max         -- Max amount per response
first       -- Id for the first item in the response
last        -- Id for the last item in the response
index       -- Used to set an index to start from
count       -- The number of remote items available

Removes the index attribute for <first> but keeps the element


Returns the value of <before>, if it is empty it will return True


Returns the value of the index attribute for <first>

interfaces: ClassVar[Set[str]] = {'after', 'before', 'count', 'first', 'first_index', 'index', 'last', 'max'}#

The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the plugin_attrib value of any registered stanza plugins.

iterables: List[ElementBase]#

A list of child stanzas whose class is included in plugin_iterables.

loaded_plugins: Set[str]#
name: ClassVar[str] = 'set'#

The XML tag name of the element, not including any namespace prefixes. For example, an ElementBase object for <message /> would use name = 'message'.

namespace: str = 'http://jabber.org/protocol/rsm'#

The XML namespace for the element. Given <foo xmlns="bar" />, then namespace = "bar" should be used. The default namespace is jabber:client since this is being used in an XMPP library.

parent: Optional[ReferenceType[ElementBase]]#

A weakref.weakref to the parent stanza, if there is one. If not, then parent is None.

plugin_attrib: ClassVar[str] = 'rsm'#

For ElementBase subclasses which are intended to be used as plugins, the plugin_attrib value defines the plugin name. Plugins may be accessed by using the plugin_attrib value as the interface. An example using plugin_attrib = 'foo':

register_stanza_plugin(Message, FooPlugin)
msg = Message()
plugins: Dict[Tuple[str, Optional[str]], ElementBase]#

An ordered dictionary of plugin stanzas, mapped by their plugin_attrib value.


Sets the value of <before>, if the value is True then the element will be created without a value


Sets the index attribute for <first> and creates the element if it doesn’t exist

sub_interfaces: ClassVar[Set[str]] = {'after', 'before', 'count', 'first', 'index', 'last', 'max'}#

A subset of interfaces which maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.

tag: str#

The name of the tag for the stanza’s root element. It is the same as calling tag_name() and is formatted as '{namespace}elementname'.

xml: ET.Element#

The underlying XML object for the stanza. It is a standard xml.etree.ElementTree object.