The error is due to the possibility of not finding a record in db.page using request.args(0) as id. Your program has to be able to deal with this eventuality.
On May 15, 4:34 am, 黄祥 <steve.van.chris...@gmail.com> wrote: > hi, > > is it possible to show multiple tables in 1 page? > > e.g. like onhttp://web2py.com/book/default/chapter/03#A-Wiki > but i want to add the comment on the index function like : > def index(): > pages = db().select(db.page.id, db.page.title, orderby = > db.page.title) > this_page = db.page(request.args(0)) > db.comment.page_id.default = this_page.id > form = crud.create(db.comment) if auth.user else None > pagecomments = db(db.comment.page_id == this_page.id).select() > return dict(pages = pages, page = this_page, comments = > pagecomments, form = form) > > my above code return an error : > > Traceback (most recent call last): > File "/home/sugizo/web2py/gluon/restricted.py", line 181, in > restricted > exec ccode in environment > File "/home/sugizo/web2py/applications/a/controllers/default.py", > line 67, in <module> > File "/home/sugizo/web2py/gluon/globals.py", line 133, in <lambda> > self._caller = lambda f: f() > File "/home/sugizo/web2py/applications/a/controllers/default.py", > line 9, in index > db.comment.page_id.default = this_page.id > AttributeError: 'NoneType' object has no attribute 'id' > > is there another way to do this? > any hints or pointer is greatly appreciate, thank you very much before