def get_acl_users_forms(self, request, object_id, template='acl/user_acl_users.html'):
        extra_context = {}
        obj = self.model.objects.get(pk=object_id)
        ct = ContentType.objects.get_for_model(obj)
        extra_context["object_name"] = unicode(obj)

        acl_template = 'acl/acl_users.html'

        if request.method == 'POST':
            selected = request.POST.getlist('_selected_action')
            selected_verbs = request.POST.getlist('_selected_verbs')
            # delete permission
            # obj.aclpermission_set.filter(object=obj,
            # user__isnull=False).delete()
            ACLPermission.objects.filter(
                object_id=obj.pk, content_type=ct, user__isnull=False).delete()

            # add permission for cchecked users
            ol = User.objects.filter(pk__in=selected)
            for u in ol:
                for ac in request.POST:
                    if ac[:5] == 'perm_' and request.POST[ac] != "":
                        acc = ac.split('_')
                        if acc[2] in selected and long(acc[2]) == u.pk:
                            self.add_perm(acc[1], obj, u, request.POST[ac])

            # add permission for new user
            u = request.POST.get("u", "")
            if u:
                u = User.objects.get(pk=u)
                check = get_acl_for_model(obj)
                for v in selected_verbs:
                    check.add_perm(v, obj, u, defines.ZORNA_PERMISSIONS_ALLOW)
            # invalidate cache
            cache.delete(ACL_USERS_PERMISSIONS_CACHE)

            redirect = request.POST.get('next', None)
            if redirect:
                if '?' not in redirect:
                    redirect = redirect + '?object_id=' + str(object_id)
                else:
                    redirect = redirect + '&object_id=' + str(object_id)
                return HttpResponseRedirect(redirect)

        extra_context["verbs"] = {}
        for k, v in self.perms.iteritems():
            extra_context["verbs"][k] = {}
            extra_context["verbs"][k]['text'] = _(v.name)

        ob_list = User.objects.filter(
            aclpermission__user__isnull=False, aclpermission__object_id=obj.pk, aclpermission__content_type=ct).distinct()
        # perm =  obj.aclpermission_set.select_related().filter(object=obj,
        # user__isnull=False)
        perm = ACLPermission.objects.select_related().filter(
            object_id=obj.pk, content_type=ct, user__isnull=False)
        dummy = ob_list
        for ob in dummy:
            ob.verbs = {}
            for k, v in self.perms.iteritems():
                ob.verbs[k] = ''
                for g in perm:
                    if g.user_id == ob.id and k == g.permission.codename:
                        ob.verbs[k] = g.acltype

        extra_context['users_list'] = dummy
        extra_context['object'] = obj
        extra_context['next'] = request.REQUEST.get('next', '')

        paginate_by = 20
        paginator = Paginator(
            ob_list._clone(), paginate_by, allow_empty_first_page=True)
        page = request.GET.get('page', 1)
        try:
            page_number = int(page)
        except __HOLE__:
            if page == 'last':
                page_number = paginator.num_pages
            else:
                # Page is not 'last', nor can it be converted to an int.
                raise Http404
        try:
            page_obj = paginator.page(page_number)
        except InvalidPage:
            raise Http404

        extra_context['paginator'] = paginator
        extra_context['page_obj'] = page_obj
        extra_context['acl_form'] = render_to_string(
            acl_template, extra_context, context_instance=RequestContext(request))
        context = RequestContext(request)
        if template:
            return render_to_response(template, extra_context, context_instance=context)
        else:
            return extra_context
dataset/ETHPy150Open zorna/zorna/zorna/acl/models.py/BaseACL.get_acl_users_forms