From 488f7ed88691d9f7fa756a28702f6bee43d6a260 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Fri, 30 Mar 2012 23:02:48 -0700 Subject: Begin experiment with a centralized API callback registry. The API registry generalizes the node handler system from the xep_0030 plugin so that other plugins can use it. --- sleekxmpp/basexmpp.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'sleekxmpp/basexmpp.py') diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py index dc1f6b94..5fcfbf6d 100644 --- a/sleekxmpp/basexmpp.py +++ b/sleekxmpp/basexmpp.py @@ -19,6 +19,7 @@ import logging import sleekxmpp from sleekxmpp import plugins, features, roster +from sleekxmpp.api import APIRegistry from sleekxmpp.exceptions import IqError, IqTimeout from sleekxmpp.stanza import Message, Presence, Iq, StreamError @@ -97,6 +98,22 @@ class BaseXMPP(XMLStream): #: ``'to'`` and ``'from'`` JIDs of stanzas. self.is_component = False + #: The API registry is a way to process callbacks based on + #: JID+node combinations. Each callback in the registry is + #: marked with: + #: + #: - An API name, e.g. xep_0030 + #: - The name of an action, e.g. get_info + #: - The JID that will be affected + #: - The node that will be affected + #: + #: API handlers with no JID or node will act as global handlers, + #: while those with a JID and no node will service all nodes + #: for a JID, and handlers with both a JID and node will be + #: used only for that specific combination. The handler that + #: provides the most specificity will be used. + self.api = APIRegistry(self) + #: Flag indicating that the initial presence broadcast has #: been sent. Until this happens, some servers may not #: behave as expected when sending stanzas. -- cgit v1.2.3