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 think....where > 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 see are simply Python (both "any" and "lambda" are plain Python constructs). Note, it doesn't have to be a lambda function -- the point is simply that if you pass a function of any kind to auth.requires(), it will call that function *later* (when the function it decorates is actually called) rather than *immediately* (when the decorator itself is defined -- which happens whenever the controller file is executed). So, by putting the test inside a function, you defer the execution of the test until it is actually needed. Because the auth.has_membership() calls each require a database select, you don't want to run those calls unless absolutely necessary. This recommendation is mentioned here: http://web2py.com/books/default/chapter/29/09/access-control#Decorators. Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.