I have found a solution, but I don't know whether this solution is efficient:
def has_membership(i): return db.auth_user.id.belongs([k['user_id']\ for k in db(db.auth_membership.group_id==i).select()]) grid = SQLFORM.smartgrid(db.auth_user, user_signature=False, linked_tables=['phone'], fields=[db.auth_user.id, db.auth_user.first_name], constraints=dict(auth_user=has_membership(1)), ) 2012/3/9 Martin Weissenboeck <mweis...@gmail.com> > YASQ 3 (yet another smartgrid question): > > Hi, I have the tables auth_group, auth_membership and auth_permission and > a smartgrid like > > grid = SQLFORM.smartgrid(db.auth_user, > user_signature=False, > linked_tables=['phone'], > fields=[db.auth_user.id, db.auth_user.first_name], > constraints=dict(auth_user=query), > ) > > I have tried some queries: > > - query = db.auth_user>0 # shows the whole table - ok > - query=auth.accessible_query('read', db.auth_user, 1) > # User 1 is a member of group "teacher" and teachers have the > permission to read some auth_user-records. > # The grid shows these auth_users, it is ok > > > Now I want to select all "auth_user"s which are members of group #1. I > want something like > > - query = auth.has_membership(group_id=1) > - query = auth.has_membership(role='teacher') > > I have tried (thanks to Anthony): > > - query =(db.auth_user.id==db.auth_membership.user_id) & > (db.auth_membership.group_id==1) > # yes, all members of group 1 are shown, but the link to the > phone-table (the "phone"-button) does not work > > Any ideas? > Regards, Martin >