def resolve()

in qpid/messaging/driver.py [0:0]


  def resolve(self, sst, name, action, force=False, node_type=None, delete=False):
    if not force and not node_type:
      try:
        type, subtype = self.address_cache[name]
        action(type, subtype)
        return
      except KeyError:
        pass

    args = { "topic":None, "queue":None }
    def do_result(r, obj):
      args[obj] = r
    def do_action():
      er = args["topic"]
      qr = args["queue"]
      if node_type == "topic" and er and not er.not_found:
        type, subtype = "topic", er.type
      elif node_type == "queue" and qr and qr.queue:
        type, subtype = "queue", None
      elif (er and er.not_found) and qr and not qr.queue:
        type, subtype = None, None
      elif (qr and qr.queue):
        if node_type == "topic" and force:
          type, subtype = None, None
        else:
          type, subtype = "queue", None
      elif (er and not er.not_found):
        if node_type == "queue" and force:
          type, subtype = None, None
        else:
          type, subtype = "topic", er.type
      elif er:
        if er.not_found:
          type, subtype = None, None
        else:
          type, subtype = "topic", er.type
      else:
        type, subtype = None, None
      if type is not None:
        self.address_cache[name] = (type, subtype)
      action(type, subtype)
    def do_result_and_action(r, obj):
      do_result(r, obj)
      do_action()
    if (node_type is None): # we don't know the type, let check broker
      sst.write_query(ExchangeQuery(name), do_result, "topic")
      sst.write_query(QueueQuery(name), do_result_and_action, "queue")
    elif force and not delete: # we forcefully declare known type, dont ask broker
      do_action()
    elif node_type == "topic":
      sst.write_query(ExchangeQuery(name), do_result_and_action, "topic")
    else:
      sst.write_query(QueueQuery(name), do_result_and_action, "queue")