Had to revert this

elif request.post_vars.modified_on != str(form.record.modified_on):
     session.flash = T('Record was changed while you were editing. '
                       'This is the updated record.')
     redirect(URL(args=request.args, vars=request.get_vars, user_signature=
True))

to this

elif request.post_vars.modified_on != str(db.client(request.vars.id).
modified_on):
     session.flash = T('Record was changed while you were editing. '
                       'This is the updated record.')
     redirect(URL(args=request.args, vars=request.get_vars, user_signature=
True))

because if the record was changed by another user while the this user was 
editing and the this user made a mistake in a field that was auto-checked 
by web2py (using the requires from the model file), the upper version would 
not catch that the record had been changed and would save the record 
instead of showing the message.

Per your suggestion, I have this in the index function (where the grid is 
created):
    if 'edit' in request.args:
        form = grid.update_form
        form['hidden'].update(modified_on=form.record.modified_on)



quinta-feira, 28 de Março de 2019 às 13:01:46 UTC, Anthony escreveu:
>
> which I changed now to this
>>
>>   elif request.post_vars.modified_on != str(db.client(request.vars.id).
>> modified_on):
>>      session.flash = T('Record was changed while you were editing. '
>>                        'This is the updated record.')
>>      redirect(URL(args=request.args, vars=request.get_vars, 
>> user_signature=True))
>>
>
> Why not put the above inside the "edit" condition, as it is not relevant 
> otherwise (and won't work on record creation)? Also, given that this is in 
> the onvalidation function, why not use form.record rather than 
> unnecessarily re-selecting the record via db.client(request.vars.id)?
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to