def get_acl_groups_forms(self, request, object_id, **kwargs):
        extra_context = {}
        obj = self.model.objects.get(pk=object_id)
        ct = ContentType.objects.get_for_model(obj)

        extra_context["object_name"] = unicode(obj)

        try:
            exclude = kwargs['exclude']
            ob_list = UserGroup.objects.exclude(pk__in=exclude).order_by('lft')
        except:
            ob_list = UserGroup.objects.all().order_by('lft')
        template = 'acl/acl_groups.html'

        extra_context["proto_perm"] = None
        perm_object = obj
        if request.method == 'POST':
            if 'bupdate' not in request.POST:
                pr = request.POST.get("proto_perm", None)
                if pr:
                    perm_object = self.model.objects.get(pk=pr)
                    extra_context["proto_perm"] = perm_object.pk
            else:
                # obj.aclpermission_set.filter(group__isnull=False).delete()
                ACLPermission.objects.filter(
                    object_id=obj.pk, content_type=ct, group__isnull=False).delete()
                temp = {}
                for ac in request.POST:
                    if ac[:5] == 'perm_' and request.POST[ac] != "":
                        acc = ac.split('_')
                        try:
                            temp[int(acc[2])].append((
                                acc[1], request.POST[ac]))
                        except __HOLE__:
                            temp[int(acc[2])] = []
                            temp[int(acc[2])].append((
                                acc[1], request.POST[ac]))

                if len(temp):
                    grp = UserGroup.objects.in_bulk(temp.keys())
                    for g_id, g in grp.iteritems():
                        for c in temp[g_id]:
                            self.add_perm(c[0], obj, g, c[1])
                perm_object = obj
                # invalidate cache
                cache.delete(ACL_USERS_PERMISSIONS_CACHE)
                cache.delete(ACL_GROUPS_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)

        # perm =
        # perm_object.aclpermission_set.select_related().filter(group__isnull=False)
        perm = ACLPermission.objects.select_related().filter(
            object_id=perm_object.pk, content_type=ct, group__isnull=False)
        parentsid = []
        for ob in ob_list:
            if ob.pk > defines.ZORNA_GROUP_REGISTERED:
                ob.show_members = True
            else:
                ob.show_members = False
            ob.verbs = {}
            for k, v in self.perms.iteritems():
                ob.verbs[k] = ''
                for g in perm:
                    if g.group_id == ob.id and k == g.permission.codename:
                        ob.verbs[k] = g.acltype
            if ob.parent_id not in parentsid:
                ob.parent_id = 0
            parentsid.append(ob.pk)
        # e =
        # ZornaEntity.objects.filter(aclpermission__object__content_type=ContentType.objects.get_for_model(obj)).distinct()
        extra_context['perm_objects'] = {}
        # for c in e:
        # c = c.as_leaf_class() #TODO A optimiser
        #    extra_context['perm_objects'].append(c)

        perm = ACLPermission.objects.select_related().filter(
            content_type=ct, group__isnull=False).exclude(object_id=obj.pk)
        for p in perm:
            try:
                extra_context['perm_objects'][
                    p.content_object.pk] = p.content_object
            except:
                pass

        extra_context['next'] = request.REQUEST.get('next', '')
        extra_context['object'] = obj
        extra_context['object_list'] = ob_list
        context = RequestContext(request)
        return render_to_response(template, extra_context, context_instance=context)
dataset/ETHPy150Open zorna/zorna/zorna/acl/models.py/BaseACL.get_acl_groups_forms