Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-20 Thread Tom Atkins
Thanks for the replies. All is working OK now. Not sure what was happening yesterday. I think I was just having one of those days... In case anyone else comes across this thread - the advice below is good: use a normal shell and make sure to do a db.commit() On 19 March 2011 14:25, rochacbruno

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-19 Thread rochacbruno
In shell you need to fire db.commit() to persist changes. Em 19/03/2011, às 10:23, Tom Atkins escreveu: > Hmm - I spoke too soon. Database changes work OK from controllers but not > from shell... > > On 19 March 2011 13:03, Tom Atkins wrote: > Oops - my mistake - I was using Navicat to lo

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-19 Thread Anthony
Are you using the web-based shell in admin? If so, try a regular Python shell instead -- the admin shell seems to have some limitations. On Saturday, March 19, 2011 9:23:37 AM UTC-4, Tom A wrote: > Hmm - I spoke too soon. Database changes work OK from controllers but not > from shell... > > O

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-19 Thread Tom Atkins
Hmm - I spoke too soon. Database changes work OK from controllers but not from shell... On 19 March 2011 13:03, Tom Atkins wrote: > Oops - my mistake - I was using Navicat to look at my sqllite database and > had left it open. hence sqllite db was locked. > > > On 19 March 2011 10:41, Tom Atki

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-19 Thread Tom Atkins
Oops - my mistake - I was using Navicat to look at my sqllite database and had left it open. hence sqllite db was locked. On 19 March 2011 10:41, Tom Atkins wrote: > Thanks Massimo - I was considering using accessible_query. > > However, I've now got a problem before I try that - auth.add_permi

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-19 Thread Tom Atkins
Thanks Massimo - I was considering using accessible_query. However, I've now got a problem before I try that - auth.add_permission doesn't seem to be working: auth.add_permission(1, 'read', db.auth_user, 0) 1 but when I look in the auth_permission table there are no entries. I've tried thi

[web2py] Re: Best way to return all users who have a specific role?

2011-03-18 Thread Anthony
The book says 'db(accessible_query(...)...' -- should it say 'db(auth. accessible_query(...)...'? http://web2py.com/book/default/chapter/08?search=accessible_query On Friday, March 18, 2011 4:08:18 PM UTC-4, Massimo Di Pierro wrote: > If you have given explicit permission to the group: > > g

[web2py] Re: Best way to return all users who have a specific role?

2011-03-18 Thread Massimo Di Pierro
If you have given explicit permission to the group: group_id=auth.add_group('Super Admin') auth.add_permission(group_id, 'read', db.mytable) then you can do: for row in db(auth.accessible_query('read', db.mytable)).select(db.mytable.ALL): print row in the case being discussed mytable is auth_us

Re: [web2py] Re: Best way to return all users who have a specific role?

2011-03-18 Thread Tom Atkins
Thank you - yes the double hit on the database was what made it seem inelegant to me. Your joined query works fine and I can work with the return data. Any further improvements gratefully received! Hoping Massimo has an undocumented super 1 liner! ;-)

[web2py] Re: Best way to return all users who have a specific role?

2011-03-18 Thread pbreit
That should be: for user in users: #2nd plural

[web2py] Re: Best way to return all users who have a specific role?

2011-03-18 Thread pbreit
I would think a join could get you there in one query. Something like: users = db((db.auth_user.id==db.auth_membership.user_id) & (db.auth_membership.group_id==db.auth_group.id) & (db.auth_group.role=='Super admin')).select() for user in user: #do something The