def _DiscoveryHandler(self,conn,request):
        """ Servers DISCO iq request from the remote client.
            Automatically determines the best handler to use and calls it
            to handle the request. Used internally.
        """
        node=request.getQuerynode()
        if node:
            nodestr=node
        else:
            nodestr='None'
        handler=self.getDiscoHandler(node,request.getTo())
        if not handler:
            self.DEBUG("No Handler for request with jid->%s node->%s ns->%s"%(request.getTo().__str__().encode('utf8'),nodestr.encode('utf8'),request.getQueryNS().encode('utf8')),'error')
            conn.send(Error(request,ERR_ITEM_NOT_FOUND))
            raise NodeProcessed
        self.DEBUG("Handling request with jid->%s node->%s ns->%s"%(request.getTo().__str__().encode('utf8'),nodestr.encode('utf8'),request.getQueryNS().encode('utf8')),'ok')
        rep=request.buildReply('result')
        if node: rep.setQuerynode(node)
        q=rep.getTag('query')
        if request.getQueryNS()==NS_DISCO_ITEMS:
            # handler must return list: [{jid,action,node,name}]
            if type(handler)==dict: lst=handler['items']
            else: lst=handler(conn,request,'items')
            if lst==None:
                conn.send(Error(request,ERR_ITEM_NOT_FOUND))
                raise NodeProcessed
            for item in lst: q.addChild('item',item)
        elif request.getQueryNS()==NS_DISCO_INFO:
            if type(handler)==dict: dt=handler['info']
            else: dt=handler(conn,request,'info')
            if dt==None:
                conn.send(Error(request,ERR_ITEM_NOT_FOUND))
                raise NodeProcessed
            # handler must return dictionary:
            # {'ids':[{},{},{},{}], 'features':[fe,at,ur,es], 'xdata':DataForm}
            for id in dt['ids']: q.addChild('identity',id)
            for feature in dt['features']: q.addChild('feature',{'var':feature})
            if dt.has_key('xdata'): q.addChild(node=dt['xdata'])
        conn.send(rep)
        raise NodeProcessed
 Servers DISCO iq request from the remote client.
            Automatically determines the best handler to use and calls it
            to handle the request. Used internally.
        
chrome-cordova/gcmServer/xmpp/browser.py