'Register a handler to process download requests, either for all
JIDs or a single JID.
Arguments:
jid     -- If None, then set the handler as a global default.
handler -- If None, then remove the existing handler for the
given JID, or reset the global handler if the JID
is None.'

def register_url_handler(self, jid=None, handler=None):

    if (jid is None):
        if (handler is not None):
            self.url_handlers['global'] = handler
        else:
            self.url_handlers['global'] = self._default_handler
    elif (handler is not None):
        self.url_handlers['jid'][jid] = handler
    else:
        del self.url_handlers['jid'][jid]
