SQLFORM.grid detect_record_change

25 views
Skip to first unread message

Otto Domínguez

unread,
Jul 9, 2014, 2:06:57 PM7/9/14
to web...@googlegroups.com
Is it possible to use detect_record_change while submitting an edit with SQLFORM.grid. I'm talking the remotely possible but still possible case where two users choose to edit the same record simultaneously. Just the first one to submit her/his change should be successful. The second one should fail because the record has changed between record retrieval to populate edit form and the submission of changes. The Book gives code snippet to use SQLFORM (not .grid) but I do not know how to put a flash message where it says "# do something HERE FROM INSIDE A SQLFORM.grid?" because this code is managed by SQLFORM.grid, not by me as the case the Book shows.
def edit_dog():
    dog = db.dog(request.args(0)) or redirect(URL('error'))
    form=SQLFORM(db.dog,dog)
    form.process(detect_record_change=True)
    if form.record_changed:
        # do something HERE FROM INSIDE A SQLFORM.grid?
    elif form.accepted:
        # do something else
    else:
        # do nothing
    return dict(form=form)

Reply all
Reply to author
Forward
0 new messages