

def create_association_mult(self, assoc_list=None):
    '\n        Create multiple associations between two IonObjects with a given predicate.\n        @param assoc_list  A list of 3-tuples of (subject, predicate, object). Subject/object can be str or object\n        '
    if (not assoc_list):
        return []
    lookup_rid = set()
    for (s, p, o) in assoc_list:
        if (type(s) is str):
            lookup_rid.add(s)
        if (type(o) is str):
            lookup_rid.add(o)
    lookup_rid = list(lookup_rid)
    lookup_obj = (self.read_mult(lookup_rid) if lookup_rid else [])
    res_by_id = dict(zip(lookup_rid, lookup_obj))
    create_ts = get_ion_ts()
    new_assoc_list = []
    for (s, p, o) in assoc_list:
        new_s = s
        new_o = o
        if (type(s) is str):
            new_s = res_by_id[s]
            if (not new_s):
                raise NotFound(('Subject %s not found' % s))
        elif ('_id' not in s):
            raise BadRequest('Subject id not available')
        if (type(o) is str):
            new_o = res_by_id[o]
            if (not new_o):
                raise NotFound(('Object %s not found' % o))
        elif ('_id' not in object):
            raise BadRequest('Object id not available')
        if (p not in Predicates):
            raise BadRequest(('Predicate unknown %s' % p))
        pt = Predicates.get(p)
        if (not (new_s.type_ in pt['domain'])):
            found_st = False
            for domt in res_by_id['domain']:
                if (new_s.type_ in getextends(domt)):
                    found_st = True
                    break
            if (not found_st):
                raise BadRequest(('Illegal subject type %s for predicate %s' % (new_s.type_, p)))
        if (not (new_o.type_ in pt['range'])):
            found_ot = False
            for rant in pt['range']:
                if (new_o.type_ in getextends(rant)):
                    found_ot = True
                    break
            if (not found_ot):
                raise BadRequest(('Illegal object type %s for predicate %s' % (new_o.type_, p)))
        assoc = IonObject('Association', s=new_s._id, st=new_s.type_, p=p, o=new_o._id, ot=new_o.type_, ts=create_ts)
        new_assoc_list.append(assoc)
    new_assoc_ids = [create_unique_association_id() for i in xrange(len(new_assoc_list))]
    return self.rr_store.create_mult(new_assoc_list, new_assoc_ids)

dataset/ETHPy150Open ooici/pyon/pyon/ion/resregistry.py ResourceRegistry.create_association_mult/VarMisuse@322/543 `pt`->`res_by_id`