Posting it again because my last post(7 days old) was not approved.
I am facing issue while updating record using SQLFORM when readable and
writable is False for id field and record_versioning is on. I am explaining
this issue with example app 'mywiki' given in web2py book
<http://www.web2py.com/books/default/chapter/29/03/overview#A-simple-wiki>.
I only added following line in db.py to enable record versioning and to
hide id field in forms. Did no changes in controller or other code.
db._common_fields.append(auth.signature)
db.define_table('page',
Field('title'),
Field('body', 'text'),
Field('created_on', 'datetime', default=request.now),
Field('created_by', 'reference auth_user',
default=auth.user_id),
format='%(title)s')
db.page.id.readable = db.page.id.writable = False
# other table definations.....
auth.enable_record_versioning(db) # at the end of file
here is edit controller function:
def edit():
"""edit an existing wiki page"""
this_page = db.page(request.args(0, cast=int)) or redirect(URL('index'))
form = SQLFORM(db.page, this_page).process(
next = URL('show', args=request.args))
return dict(form=form)
Now when I submit the update form without updating anything in form,
I got error- KeyError: 'id' Here is complete traceback
https://paste.ubuntu.com/23442757/
I debugged through web2py framework code and found that error comes while
creating entry in archive table, and only when writable False and that to
for id field because _filter_fields filters out id field.
I think, I am missing something simple here I am using web2py-2.14.6.
Also posted this on stackoverflow
<http://stackoverflow.com/questions/40478479/update-sqlform-gives-keyerror>
Please help me to fix the error!
Thank You
--
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.