I think the row object submitted to the compute function only includes the
fields that are part of the update, so it won't include row['f_revision'].
Instead, you could get the record id from request.vars and use that to
query the current value of the f_revision field:
db.define_table('t_templates', Field('name'),
Field('f_template', 'upload', label=T('File'), notnull=True),
Field('f_revision', 'integer', label=T('Revision'),
compute=lambda: db.t_templates(request.vars.id).f_revision + 1 if (
request.vars.id and
request.vars._formname and request.vars_formname.startswith(
't_templates')) else 1))
Anthony
On Tuesday, May 1, 2012 7:31:43 AM UTC-4, François Delpierre wrote:
>
> Hi,
>
> Here is exactly what I would like to have, but it does not compute on
> update :
>
> db.define_table('t_templates',
> Field('f_template', type='upload', label=T('File'),notnull=True),
>
>
> Field('f_revision', type='integer', label=T('Revision'),
> default=1,
> compute=lambda row: row['f_revision']+1 ,
> ),
> )
>
>