Hello
I am trying to get user's role looking into membership table etc.
Following all the codes on majority of forums my code does not work.
this is my controller
from gluon.tools import Auth
database = request.cookies['mycookie'].value
db = DAL('postgres://postgres:[email protected]/' + database,
migrate=False)
auth = Auth(db)
def index():
if not auth.is_logged_in():
login_adress= auth.settings.login_url = URL('user','user',
args='login')
redirect (login_adress)
print auth.user_id ###Works
print auth.user_group ### result is <bound method Auth.user_group of
<gluon.tools.Auth object at 0x000000000A307F28>>
print auth.has_membership(auth.id_group('Member'),auth.user.id)
<type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'role'
Also, If I try with some DAL select sentances none of them work. error is
usually
if code is
rows = db(db.auth_user).select()
or
rows = db((db.auth_user.email ==
auth.user.email)&(db.auth_membership.user_id ==
auth.user_id)&(db.auth_group.id==db.auth_membership.group_id)).select(db.auth_group.ALL)
error is
<type 'exceptions.KeyError'> 'auth_user'
what am I doing wrong here. It is a f#"$"# simple ask. Get user role so I
can get a user a specific view based on that role (btw any suggestions on
that would be nice).
thank you
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.