code: def _resolve_ondemand(self, macro, data):
          elts = macro.split(':')
          nb_parts = len(elts)
          macro_name = elts[0]
          if nb_parts == 3:
              val = ''
              (host_name, service_description) = (elts[1], elts[2])
              if host_name == '':
                  for elt in data:
                      if elt is not None and elt.__class__ == self.host_class:
                          host_name = elt.host_name
              serv = self.services.find_srv_by_name_and_hostname(host_name, service_description)
              if serv is not None:
                  cls = serv.__class__
                  prop = cls.macros[macro_name]
                  val = self._get_value_from_element(serv, prop)
                  return val
          else:
              val = ''
              elt_name = elts[1]
              if elt_name == '':
                  for elt in data:
                      if elt is not None and elt.__class__ == self.host_class:
                          elt_name = elt.host_name
              for od_list in self.lists_on_demand:
                  cls = od_list.inner_class
                  if macro_name in cls.macros:
                      prop = cls.macros[macro_name]
                      i = od_list.find_by_name(elt_name)
                      if i is not None:
                          val = self._get_value_from_element(i, prop)
                          break
              return val
          return 'n/a'