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/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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to