

def populate_instance(self, instance, id_map):
    if self.backref:
        for field in self.fields:
            identifier = instance._data[field.name]
            key = (field, identifier)
            if (key in id_map):
                setattr(instance, field.name, id_map[key])
    else:
        for (field, attname) in self.field_to_name:
            identifier = instance._data[field.to_field.name]
            key = (field, identifier)
            rel_instances = id_map.get(key, [])
            dest = ('%s_prefetch' % field.related_name)
            for inst in rel_instances:
                setattr(inst, attname, identifier)
            setattr(instance, dest, rel_instances)

dataset/ETHPy150Open coleifer/peewee/peewee.py PrefetchResult.populate_instance/VarMisuse@148/181 `instance`->`identifier`