I do not think this does what asked because it will match everybody. This
should work:
group_id = auth.id_group('<role name>')
all_users_in_group =
db(db.auth_membership.group_id==group_id)._select(db.auth_membership.user_id)
users = db(!db.auth_user.id.belongs(all_users_in_group)).select()
On Friday, 31 May 2013 21:42:17 UTC-5, Alan Etkin wrote:
>
>
>
>> I was wondering how to select all users not in a group with a certain
>> role.
>>
> Perhaps there's a better way, but here's a recipe:
>
> group_id = db(db.auth_group.role=="<role name>").select().id
> users = db((db.auth_user.id
> ==db.auth_membership.user_id)&(db.auth_membership.group_id!=group_id)).select()
>
> The adapter must support join queries (postgres, sqlite, ...). Otherwise
> you could first get the group id, then all memberships not matching the
> group_id and finally retrieve each user with a select (or the complete set
> using a list of user ids and the belongs operator if available)
>
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.