web2py doesn't know if a field has been edited or not. form.vars (for a 
standard web2py form) holds EVERY value, irregardless of the ones touched 
or not by the user... 

On Thursday, March 5, 2015 at 4:17:26 PM UTC+1, Richard wrote:
>
> Futher check make me confirm which I thought : 
>
> **{f: v for f, v in form.vars.iteritems()}
>
> Prevent my compute to work since it return only the fields modify by the 
> user... I need to understand how web2py really update on form submit and 
> why compute works in this case...
>
> Or how can I make sure that every fields get update even if there is not 
> any values change which should be what web2py do...
>
> Richard
>
> On Wed, Mar 4, 2015 at 5:05 PM, Anthony <abas...@gmail.com <javascript:>> 
> wrote:
>
>> The update should calculate the computed field as long as all the values 
>> needed for the calculation are included with the update.
>>
>> Anthony
>>
>>
>> On Wednesday, March 4, 2015 at 4:55:01 PM UTC-5, Richard wrote:
>>>
>>> Thanks for answering Anthony,
>>>
>>> Actually f1 and f2 belongs to the table, I am filtering them because I 
>>> want to treat them separately... 
>>>
>>> About your question, I am investigating why my compute didn't work... My 
>>> first impression is that it is not include in form.vars so it not get hit 
>>> at all... But I am not sure of that...
>>>
>>> Richard
>>>
>>> On Wed, Mar 4, 2015 at 4:44 PM, Anthony <abas...@gmail.com <javascript:>
>>> > wrote:
>>>
>>>> Does form.vars include all the variables needed by the compute function?
>>>>
>>>> Also, instead of:
>>>>
>>>> **{f: v for f, v in form.vars.iteritems()}
>>>>
>>>> you can do:
>>>>
>>>> **db[request.args(0)]._filter_fields(form.vars)
>>>>
>>>> _filter_fields will filter out the "id" field as well as any form.vars 
>>>> that are not fields in the table.
>>>>
>>>> Anthony
>>>>
>>>>
>>>>
>>>>
>>>> On Wednesday, March 4, 2015 at 4:35:37 PM UTC-5, Richard wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I need to do control record update in order to clear some fields 
>>>>> values in case a flag is set to false. But doing the update like this :
>>>>>
>>>>>
>>>>> db(db[request.args(0)].id == request.args(1)).update(**{f: v for f, v 
>>>>> in form.vars.iteritems()})
>>>>>
>>>>> prevent a compute field to be trigger and updating properly as well...
>>>>>
>>>>> So, to make sure my compute field get it I am doing another update() 
>>>>> like this
>>>>>
>>>>>
>>>>> db(db[request.args(0)].id == request.args(1)).update()
>>>>>
>>>>>
>>>>> Which work in one case by not in the other where I actually clear some 
>>>>> values like this :
>>>>>
>>>>>
>>>>> db(db[request.args(0)].id == request.args(1)).update(f1=None, f2=None, 
>>>>> **{f: v for f, v in form.vars.iteritems() if f not in ('f1', 'f2')})
>>>>>
>>>>>
>>>>> Maybe I should do a db.commit() before my second "blank" update() 
>>>>> though it seems to me that it should be a better way and I am concern in 
>>>>> reducing db hit.
>>>>>
>>>>> Thanks
>>>>>
>>>>> Richard
>>>>>
>>>>>  -- 
>>>> 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+un...@googlegroups.com <javascript:>.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> 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+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

Reply via email to