Now it makes much more sense for me, i'm coming from PHP programming!!!
Thanks.

Il giorno venerdì 3 luglio 2015 23:38:00 UTC+2, Anthony ha scritto:
>
> A lambda function is just an anonymous function (i.e., one you define in 
> place without naming it). The common_filter does not have to be a lambda 
> function -- it can be any callable object that takes a single argument and 
> returns a Query object. So, you could do:
>
> def my_common_filter(query):
>     return db.blog_post.is_public == True
> db.blog_post._common_filter = my_common_filter
>
> When the common filter function is called, the current query will be 
> passed to it. In the above example, that query argument is ignored, but in 
> theory, you could inspect that query argument and have the return value 
> depend on it somehow. The final query will end up being a conjunction of 
> the original query and the return value of the common filter function.
>
> Also, note that the argument of the common filter function (whether a 
> lambda function or otherwise) does not have to be "query" -- that is just a 
> convention to remind you that the original query will be passed into the 
> function. You can name that argument whatever you want.
>
> Anthony
>
> On Friday, July 3, 2015 at 12:00:22 PM UTC-4, Paolo Amboni wrote:
>>
>> Can someone translate the expression
>>
>> db.blog_post._common_filter = *lambda query:* db.blog_post.is_public == 
>> True
>>
>> *without the use of lambda function?*
>>
>> I'm trying to understand how to set up common filter in controller but 
>> lambda function always confuse me.
>>
>> *So, for now, the only way to set the filter is to copy the code without 
>> understanding it!!*
>>
>

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