On 24 nov, 21:43, Massimo Di Pierro <[email protected]>
wrote:
> Anthony is right
>  if you catch the exception yourself web2py stll commits because does
> not detect failure. If catch the exception and want to rollback you
> have to be explicit. Still. It is in a transaction.

Ok, I understand, this work. Now I ask how I can solve the following:

tb_1 = db.define_table('t1',
    Field('field1'),
    Field('field2', 'integer'),
    Field('field3', 'upload', autodelete=True),
)

tb_2 = db.define_table('t2',
    Field('field1'),
    Field('field2', 'integer')
)

Note ---> autodelete=True
I need it to be this way

in this case is a update

def test():
    form = SQLFORM(tb_1, 1)
    if form.accepts(request.vars, session):
        try:
            tb_2.insert(field1='test', field2='1xbx123')

        except:
            db.rollback()
            redirect(URL('error'))
        redirect(URL('test'))
    elif form.errors:
        response.flash = 'errors'
    return dict(form=form)

thus lose the original file uploaded

Jose

Reply via email to