'Set up both the user and group caches.'

def _get_user_cached_perms(self):

    if (not self.user):
        return ({}, {})
    group_pks = set(self.user.groups.values_list('pk', flat=True))
    perms = Permission.objects.filter((Q(user__pk=self.user.pk) | Q(group__pk__in=group_pks)))
    user_permissions = {}
    group_permissions = {}
    for perm in perms:
        if (perm.user_id == self.user.pk):
            user_permissions[(perm.object_id, perm.content_type_id, perm.codename, perm.approved)] = True
        else:
            group_permissions[(perm.object_id, perm.content_type_id, perm.codename, perm.approved)] = True
    return (user_permissions, group_permissions)
