XEP-0059: Result Set Management#
- class slixmpp.plugins.xep_0059.XEP_0059(xmpp, config=None)[source]#
XEP-0059: Result Set Management
- dependencies: ClassVar[Set[str]] = {'xep_0030'}#
Some plugins may depend on others in order to function properly. Any plugin names included in
dependencies
will be initialized as needed if this plugin is enabled.
- description: str = 'XEP-0059: Result Set Management'#
A longer name for the plugin, describing its purpose. For example, a plugin for XEP-0030 would use ‘Service Discovery’ as its description value.
- 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.
- Parameters:
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 theinterface
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:
- name: str = 'xep_0059'#
A short name for the plugin based on the implemented specification. For example, a plugin for XEP-0030 would use ‘xep_0030’.
- 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
Example:
q = Iq() q['to'] = 'pubsub.example.com' q['disco_items']['node'] = 'blog' async for i in ResultIterator(q, 'disco_items', '10'): print(i['disco_items']['items'])
-
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”
-
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
-
amount:
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"> <max>2</max> </set> </query> </iq> <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"> <first>conference.example.com</first> <last>pubsub.example.com</last> </set> </query> </iq>
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
- 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.
- name: ClassVar[str] = 'set'#
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBase
object for<message />
would usename = 'message'
.
- namespace: str = 'http://jabber.org/protocol/rsm'#
The XML namespace for the element. Given
<foo xmlns="bar" />
, thennamespace = "bar"
should be used. The default namespace isjabber:client
since this is being used in an XMPP library.
- plugin_attrib: ClassVar[str] = 'rsm'#
For
ElementBase
subclasses which are intended to be used as plugins, theplugin_attrib
value defines the plugin name. Plugins may be accessed by using theplugin_attrib
value as the interface. An example usingplugin_attrib = 'foo'
:register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- set_before(val)[source]#
Sets the value of <before>, if the value is True then the element will be created without a value
- set_first_index(val)[source]#
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.