'Sets the handler callable that will be used to handle an incoming
federation Query of the given type.
Args:
query_type (str): Category name of the query, which should match
the string used by make_query.
handler (callable): Invoked to handle incoming queries of this type
handler is invoked as:
result = handler(args)
where \'args\' is a dict mapping strings to strings of the query
arguments. It should return a Deferred that will eventually yield an
object to encode as JSON.'

def register_query_handler(self, query_type, handler):

    if (query_type in self.query_handlers):
        raise KeyError(('Already    have    a    Query    handler    for    %s' % (query_type,)))
    self.query_handlers[query_type] = handler
