Ok, I think I solve my issues... I had many issues :

First has you said the compute field were not receive all it needs. I solve
this one like this :

form.process().accepted:
        for r in session.rows:
        row = db[request.args(0)](r.id)
        row.update_record(review='TRUE', other_field1=row.other_field1,
etc.)

But there were still a little issue in the way : reveiw='TRUE'

Since in my compute function I was checking for review is True, it was not
working since 'TRUE' was not translated into True because the record wasn't
inserted yet, so I guess my compute function was receiving the raw input.

Damn it!

:)

So now :

row.update_record(review=True, other_field1=row.other_field1, etc.)

Works fine...

Thanks for help.

Richard


On Tue, Jun 25, 2013 at 9:58 AM, Richard Vézina <ml.richard.vez...@gmail.com
> wrote:

> I will try to pack a little app...
>
> Richard
>
>
> On Fri, Jun 21, 2013 at 4:40 PM, Massimo Di Pierro <
> massimo.dipie...@gmail.com> wrote:
>
>> It should. Can you provide a concrete example?
>>
>>
>> On Friday, 21 June 2013 10:31:45 UTC-5, Richard wrote:
>>
>>> Further code review lead me to the conclusion that the issue is not
>>> because compute don't get all it needs to compute... I mean I get the row
>>> and since it is a update every field are available in the row and I still
>>> need to redefine the compute field...
>>>
>>> Should computed field computes on db.table(id).update_record(**key=value,
>>> key=value, ...)?
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>>
>>> On Thu, Jun 20, 2013 at 5:09 PM, Richard Vézina 
>>> <ml.richa...@gmail.com>wrote:
>>>
>>>>  Ok, yes, it may not have some field that are to None... I had issue
>>>> with that that I have patch my compute function for. I should be the 
>>>> same...
>>>>
>>>> Thank you Massimo to point me this out.
>>>>
>>>> Richard
>>>>
>>>>
>>>> On Thu, Jun 20, 2013 at 5:02 PM, Massimo Di Pierro <
>>>> massimo....@gmail.com> wrote:
>>>>
>>>>> I think the problem is that your form does not contain enough info for
>>>>> the computed field. You correctly pull them from DB (in row) and pass to
>>>>> the compute function.
>>>>>
>>>>>
>>>>> On Thursday, 20 June 2013 12:13:16 UTC-5, Richard wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I don't understand why I have to redefine my compute field function...
>>>>>>
>>>>>> I have a compute field like this one :
>>>>>>
>>>>>> # model
>>>>>> db.define_table('mytable',
>>>>>>     Field('f1', 'string'),
>>>>>>     Field('review', 'boolean'),
>>>>>>     Field('record_review_status', compute=lambda record:
>>>>>> return_computed(record, request.args(0)))
>>>>>>
>>>>>> # contoller
>>>>>> def fun():
>>>>>>     form = SQLFORM.factory(Field(...))
>>>>>>     session.rows = db(db[request.args(0)].review == False).select()
>>>>>>     table = SQLTABLE(session.rows...)
>>>>>>     form.process().accepted:
>>>>>>         for r in session.rows:
>>>>>>         row = db[request.args(0)](r.id)
>>>>>>         row.update_record(review='**TRUE**')
>>>>>>         db.commit()
>>>>>>         row = db[request.args(0)](r.id)
>>>>>>         *row.record_review_status = return_record_review_status(row,
>>>>>> request.args(0)) # here I need to redefine my record_review_status 
>>>>>> compute
>>>>>> field or it not get computed*
>>>>>>         row.update_record()
>>>>>>         db.commit()
>>>>>>     ...
>>>>>>
>>>>>> Note : It is pseudo code, so it may seems dumb or not working, I just
>>>>>> try to make an example of what going on in my app...
>>>>>>
>>>>>> In the book it is said that if we try to update record without
>>>>>> passing, web2py tries to compute compute field base on orther field
>>>>>> value...
>>>>>>
>>>>>> http://web2py.com/books/**defaul**t/chapter/29/06?search=**compute**
>>>>>> #Computed-fields<http://web2py.com/books/default/chapter/29/06?search=compute#Computed-fields>
>>>>>>
>>>>>> By the way, this part of the book is not pretty clear... For instance
>>>>>> do I have to leave update() of update_record() blank in order to get my
>>>>>> compute field to be computed.
>>>>>>
>>>>>> Also, it is not exactly clear to me why my compute field not get
>>>>>> compute on row.update_record(review='**TRUE**')... What I understand
>>>>>> is that I need to explicitly update my compute field, but the way to do 
>>>>>> it
>>>>>> seems to passing not paramaters to update() or update_record().
>>>>>>
>>>>>> In my case, it seems that my compute function can't get the 'TRUE'
>>>>>> for review only once the update(review='TRUE') is committed... I try to
>>>>>> remove the line in bold, because it already in my model, but it is not
>>>>>> working, my compute field never get updated it status.
>>>>>>
>>>>>> Thanks to clarify this to me.
>>>>>>
>>>>>> Richard
>>>>>>
>>>>>  --
>>>>>
>>>>> ---
>>>>> 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.
>>>>>
>>>>> For more options, visit 
>>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>  --
>>
>> ---
>> 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/groups/opt_out.
>>
>>
>>
>
>

-- 

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


Reply via email to