'Register an API callback, with JID+node specificity.
The API callback can later be executed based on the
specificity of the provided JID+node combination.
See :meth:`~ApiRegistry.run` for more details.
:param string ctype: The name of the API to use.
:param string op: The API operation to perform.
:param JID jid: Optionally provide specific JID.
:param string node: Optionally provide specific node.'

def register(self, handler, ctype, op, jid=None, node=None, default=False):

    self._setup(ctype, op)
    if ((jid is None) and (node is None)):
        if (handler is None):
            handler = self._handler_defaults[op]
        self._handlers[ctype][op]['global'] = handler
    elif ((jid is not None) and (node is None)):
        self._handlers[ctype][op]['jid'][jid] = handler
    else:
        self._handlers[ctype][op]['node'][(jid, node)] = handler
    if default:
        self.register_default(handler, ctype, op)
