[web2py] Re: compute and after_insert callback on table

2016-01-24 Thread 黄祥
my exact code : def on_define_default_size(table): # compute #table.total_square_meter.compute = lambda r: (float(r['length_in_cm'] ) * float(r['width_in_cm'] ) ) / 1 # label table.name.label = T('Name') table.length_in_cm.label = T('Length in Cm') table.width_in_cm.label = T('Width in Cm') t

[web2py] Re: compute and after_insert callback on table

2016-01-24 Thread Anthony
Are you showing your exact code, because the particular error reported will only appear if the computed field is required, and you have not set the total_square_meter field to be required? Anthony On Saturday, January 23, 2016 at 9:31:18 PM UTC-5, 黄祥 wrote: > > still face the same error : > e.g

[web2py] Re: compute and after_insert callback on table

2016-01-24 Thread Niphlod
I think the main point is that for a computed field you need to pass fields which happens to be the factors of the calculation: how can pydal compute the value if you don't pass the actual values are needed to compute ??? that being said, if you are using database callbacks you can just use that

[web2py] Re: compute and after_insert callback on table

2016-01-23 Thread 黄祥
still face the same error : e.g. db.define_table('default_size', Field('name'), Field('length_in_cm', 'double'), Field('width_in_cm', 'double'), Field('total_square_meter', 'double'), Field('acquisition_price', 'integer') ) db.default_size.total_square_meter.compute = lambda r: (float(r['length_