'Prefetches the permissions for objects in ``objects`` and puts them in the cache.
:param objects: Iterable of Django model objects'

def prefetch_perms(self, objects):

    if (self.user and (not self.user.is_active)):
        return []
    User = get_user_model()
    (pks, model, ctype) = _get_pks_model_and_ctype(objects)
    if (self.user and self.user.is_superuser):
        perms = list(chain(*Permission.objects.filter(content_type=ctype).values_list(u'codename')))
        for pk in pks:
            key = (ctype.id, force_text(pk))
            self._obj_perms_cache[key] = perms
        return True
    group_model = get_group_obj_perms_model(model)
    if self.user:
        fieldname = (u'group__%s' % (User.groups.field.related_query_name(),))
        group_filters = {fieldname: self.user}
    else:
        group_filters = {u'group': self.group}
    if group_model.objects.is_generic():
        group_filters.update({u'content_type': ctype, u'object_pk__in': pks})
    else:
        group_filters.update({u'content_object_id__in': pks})
    if self.user:
        model = get_user_obj_perms_model(model)
        user_filters = {u'user': self.user}
        if model.objects.is_generic():
            user_filters.update({u'content_type': ctype, u'object_pk__in': pks})
        else:
            user_filters.update({u'content_object_id__in': pks})
        user_perms_qs = model.objects.filter(**user_filters).select_related(u'permission')
        group_perms_qs = group_model.objects.filter(**group_filters).select_related(u'permission')
        perms = chain(user_perms_qs, group_perms_qs)
    else:
        perms = chain(*(group_model.objects.filter(**group_filters).select_related(u'permission'),))
    for obj in objects:
        key = self.get_local_cache_key(obj)
        if (key not in self._obj_perms_cache):
            self._obj_perms_cache[key] = []
    for perm in perms:
        if type(perm).objects.is_generic():
            key = (ctype.id, perm.object_pk)
        else:
            key = (ctype.id, force_text(perm.content_object_id))
        self._obj_perms_cache[key].append(perm.permission.codename)
    return True
