This is my code for the another table (it has the same situation, but
without using a SQLFORM.factory).
I posted this instead of the SQLFORM.factory, because it is simpler code.
My index function contains the grid
grid = SQLFORM.grid(
query,
csv=False, deletable=False, details=False,
links=[
lambda row: A(
SPAN(T('Delete'), _class='buttontext button', _title=
'Delete'),
_href=URL('get_approval', args=[row.id], user_signature=
True),
_class='button btn btn-default btn-secondary',
),
],
onvalidation=on_validation, # Form only.
orderby=db.client.name,
paginate=session.auth.user.pagination,
# represent_none='', # Grid and view form only.
)
if 'edit' in request.args:
form = grid.update_form
form['hidden'].update(modified_on=form.record.modified_on)
My onvalidation function
if request.args and request.args[0] == 'new':
# Fix for SQLite instead of for_update=True. When for_update is
# fixed for SQLite, only the first SELECT in the function should
# have for_update=True.
while True:
try:
# SQLite only does database lock.
db.executesql('BEGIN IMMEDIATE TRANSACTION')
break
except sqlite3.OperationalError:
sleep(0.5)
elif not db.client(request.vars.id).is_active:
session.flash = T('Record was deleted while you were editing.')
redirect(URL('index', user_signature=True))
elif request.post_vars.modified_on != str(db.client(request.vars.id).
modified_on):
form.errors.code = T('Record was changed while you were editing. '
'Press F5 to refresh and press Resend in the '
'browser question.')
elif form.vars.delete_this_record:
# Fix for SQLite instead of for_update=True. When for_update is
# fixed for SQLite, only the first SELECT in the function should
# have for_update=True.
while True:
try:
# SQLite only does database lock.
db.executesql('BEGIN IMMEDIATE TRANSACTION')
break
except sqlite3.OperationalError:
sleep(0.5)
db.client(request.vars.id).update_record(
cancel_approved_by=auth.user_id,
canceled_by=auth.user_id,
canceled_on=request.now,
is_active=False,
)
db.commit()
session.flash = T('Done.')
redirect(URL(user_signature=True))
elif request.args and request.args[0] == 'edit':
# Fix for SQLite instead of for_update=True. When for_update is
# fixed for SQLite, only the first SELECT in the function should
# have for_update=True.
while True:
try:
# SQLite only does database lock.
db.executesql('BEGIN IMMEDIATE TRANSACTION')
break
except sqlite3.OperationalError:
sleep(0.5)
quarta-feira, 27 de Março de 2019 às 18:47:33 UTC, Anthony escreveu:
>
> Need to see your code.
>
> On Wednesday, March 27, 2019 at 2:47:01 PM UTC-4, João Matos wrote:
>>
>> You mean to update the editing form with the new values from the record
>> on the db without telling the user to press F5?
>> How can I do it?
>>
>> Thanks.
>>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.