thanks all for the detail explanation, learn a lot new things today
{{=DIV(auth.user_groups) }}
*result :*
{1L: 'Admin', 2L: 'User'}

{{=DIV(auth.user_groups.values() ) }}
*result :*
AdminUser

{{=set(auth.user_groups.values() ) }}
*result :*
set(['Admin', 'User'])

now about hitting database, just want to clarify in web2py there is 
auth.has_membership()
*e.g.*
*controllers/default.py*
"""
*# 1 usually used*
has_membership_admin = auth.has_membership(role = 'Admin')
"""

*# 2 learn today*
has_membership_admin = 'Admin' in auth.user_groups.values()

def test():
table = db.test
grid = SQLFORM.grid(table, deletable = has_membership_admin)
return locals()

did the #2 is faster than #1 because #2 didn't hit database?

thanks and best regards,
stifan

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

Reply via email to