But what about your first example, without the try...except? Are you saying 
that if the other_table.insert() fails, the doc.update_record() still 
succeeds in committing? I don't think that should be the case. If there's 
an uncaught exception before the response is returned, web2py should roll 
back any open transactions.

Anthony

On Thursday, November 24, 2011 2:11:19 PM UTC-5, Jose wrote:
>
> On 24 nov, 15:31, Massimo Di Pierro <massimo....@gmail.com>
> wrote:
> > They run in the same transactions by default.
>
> Nop!
> Please see the following example
>
>
> model:
>
> tb_1 = db.define_table('t1',
>     Field('field1'),
>     Field('field2', 'integer')
> )
>
> tb_2 = db.define_table('t2',
>     Field('field1'),
>     Field('field2', 'integer')
> )
>
> controller:
>
> def test():
>     form = SQLFORM(tb_1)
>     if form.accepts(request.vars, session):
>         try:
>             tb_2.insert(field1='test', field2='1dfdfh') #field2 is
> integer, must be a mistake
>             redirect(URL('test'))
>         except:
>             redirect(URL('error'))
>     elif form.errors:
>         response.flash = 'errors'
>     return dict(form=form)
>
> def error():
>     return dict()
>
>
> despite the error, the record is inserted in tb_1. And I believe so,
> because first submit occurs. So I asked how to include submit and
> subsequent actions in a tranasaccion.
>
> Jose
>
>

Reply via email to