To insert/update record with .factory() you can do something like that :
if form.process().accepted:
if condition when update mode is not meat:
id = db.underlying_table.insert(field1=form.vars.field1, ...) # You keep the id in cas you need it to insert some information in another table.
elif condition when update form mode:
db(db.underlying_table.record_id == request.vars.record_id).update(field1=form.vars.field1)
And you can consider a dict comprehension so you don't actually have to write too much :
id = db.lotns_sample.insert(**{str(var): form.vars[var] for var in form.vars}) # You can filter form.vars to make sure you insert only the proper fields into the proper table in case you have fields from differents tables in you .factory() form.
:)
You can also use the web2py function to filter the field :
id = db.underlying_table.insert(**db.underlying_table._filter_fields(form.vars))
Richard