Here is a block of code that I added to the views/default/user.html
template of my application in order to debug a permission issue.
I am posting it here the hope that it is useful to others.
{{
if request.args(0)=='not_authorized':
groups = db(db.auth_membership.user_id ==
auth.user.id).select(db.auth_membership.group_id)
group_ids = [group.group_id for group in groups]
group_details =
db(db.auth_group.id.belongs(group_ids)).select(db.auth_group.id,
db.auth_group.role)
rows = db.executesql('SELECT group_id, name, table_name, record_id FROM
auth_permission ORDER BY group_id', as_dict=True)
}}
<h3>User groups:</h3>
<ul>
{{for group in group_details:}}
<li>{{=group['id']}}: {{=group['role']}}</li>
<ul>
{{for row in rows:
if row['group_id']!= group['id']: continue}}
<li>{{=row['name']}} {{=row['table_name']}}</li>
{{pass}}
</ul>
{{pass}}
</ul>
{{
pass
}}
--
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.