[web2py] Re: @auth.requires for functions

2017-04-23 Thread Andrea Fae'
Il giorno giovedì 20 aprile 2017 16:31:31 UTC+2, Andrea Fae' ha scritto: > > Hello, if I have to get the list from database, where I need to put the > code? At the start of default.py where I use the functions? Thanks > > Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: >>

[web2py] Re: @auth.requires for functions

2017-04-20 Thread Andrea Fae'
Hello, if I have to get the list from database, where I need to put the code? At the start of default.py where I use the functions? Thanks Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: > > First, when using auth.requires(), it is best to put the test inside a > lambda (o

[web2py] Re: @auth.requires for functions

2017-04-20 Thread Anthony
On Thursday, April 20, 2017 at 8:36:46 AM UTC-4, Andrea Fae' wrote: > > But... "any"? I need some more information about lambda I thinkwhere > to find this syntax with any? > where is written what you told about evaluation? > Remember, web2py is a Python framework -- many of the things you se

Re: [web2py] Re: @auth.requires for functions

2017-04-20 Thread Andrea Fae'
Thanks Il giorno giovedì 20 aprile 2017 15:40:33 UTC+2, Marvix ha scritto: > > https://docs.python.org/2/library/functions.html#any > > def any(iterable): > for element in iterable: > if element: > return True > return False > > so any() return true if one (or more) of

Re: [web2py] Re: @auth.requires for functions

2017-04-20 Thread Marvi Benedet
https://docs.python.org/2/library/functions.html#any def any(iterable): for element in iterable: if element: return True return False so any() return true if one (or more) of the elements is True. this: auth.has_membership(role) for role in list_of_roles try all th

[web2py] Re: @auth.requires for functions

2017-04-20 Thread Andrea Fae'
But... "any"? I need some more information about lambda I thinkwhere to find this syntax with any? where is written what you told about evaluation? Thank you very much Il giorno mercoledì 19 aprile 2017 17:30:06 UTC+2, Anthony ha scritto: > > First, when using auth.requires(), it is best to p

[web2py] Re: @auth.requires for functions

2017-04-19 Thread Anthony
First, when using auth.requires(), it is best to put the test inside a lambda (or standard function) so it will not be evaluated until the decorated function is actually called (otherwise, the test will be evaluated whenever the controller file is accessed). Anyway, you can do something like th