On Monday, August 19, 2013 10:11:17 PM UTC-7, Fabiano wrote:

> Almost ;)
>
> @auth.requires(auth.has_membership('Administrator') or auth.has_membership
> ('Manager'))
>

Better to put the condition in a lambda so it only gets evaluated when the 
decorated function is called rather than every time the controller is 
called:

@auth.requires(lambda: auth.has_membership('Administrator') or auth.
has_membership('Manager'))

We should probably update the book example, as this issue is mentioned 
immediately before the example.

And if you have a long list of roles to check, you can do something like:

@auth.requires(lambda: any([auth.has_membership(r) for r in ['list', 'of', 
'roles']))

Anthony

-- 

--- 
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/groups/opt_out.

Reply via email to