Changeset 22:9edffdf4aee4


Ignore:
Timestamp:
Jun 10, 2008, 8:12:33 PM (12 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@52
Message:

Clarify use of IQHandlerMixin, fix some doc strings.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r19 r22  
    390390    handled as follows:
    391391
    392     * If the exception is an instance of L{error.StanzaError}, an error
    393       response iq is returned.
    394     * Any other exception is reported using L{log.msg}. An error response
    395       with the condition C{internal-server-error} is returned.
     392     - If the exception is an instance of L{error.StanzaError}, an error
     393       response iq is returned.
     394     - Any other exception is reported using L{log.msg}. An error response
     395       with the condition C{internal-server-error} is returned.
    396396
    397397    The default implementation of said methods raises an L{Unsupported}
     
    402402    @ivar pubSubFeatures: List of supported publish-subscribe features for
    403403                          service discovery, as C{str}.
    404     @type pubSubFeatures: C{list} or C{None}.
     404    @type pubSubFeatures: C{list} or C{None}
    405405    """
    406406
  • wokkel/subprotocols.py

    r8 r22  
    235235    response of C{internal-server-error} to be sent.
    236236
     237    A typical way to use this mixin, is to set up L{xpath} observers on the
     238    C{xmlstream} to call handleRequest, for example in an overridden
     239    L{XMPPHandler.connectionMade}. It is likely a good idea to only listen for
     240    incoming iq get and/org iq set requests, and not for any iq, to prevent
     241    hijacking incoming responses to outgoing iq requests. An example:
     242
     243        >>> QUERY_ROSTER = "/query[@xmlns='jabber:iq:roster']"
     244        >>> class MyHandler(XMPPHandler, IQHandlerMixin):
     245        ...    iqHandlers = {"/iq[@type='get']" + QUERY_ROSTER: 'onRosterGet',
     246        ...                  "/iq[@type='set']" + QUERY_ROSTER: 'onRosterSet'}
     247        ...    def connectionMade(self):
     248        ...        self.xmlstream.addObserver(
     249        ...          "/iq[@type='get' or @type='set']" + QUERY_ROSTER,
     250        ...          self.handleRequest)
     251        ...    def onRosterGet(self, iq):
     252        ...        pass
     253        ...    def onRosterSet(self, iq):
     254        ...        pass
     255
    237256    @cvar iqHandlers: Mapping from XPath queries (as a string) to the method
    238257                      name that will handle requests that match the query.
Note: See TracChangeset for help on using the changeset viewer.