> 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.


Reply via email to