Hi, I tried your code an I got the same error. It pointed to the first line of your code gave the same error , I guess the first record is 0 so the code is pointing to the first record? Thanks for your help Jim Error ticket for "images" Ticket 127.0.0.1.2009-08-07.11-47-01.0a2ffb3a-0bf3-4565-88e2-6c2c572178d0
Error traceback 1.2.3.4.5.6.7. Traceback (most recent call last): File "gluon/ restricted.py", line 178, in restricted File "C:/web2py_win(2)/web2py/ applications/images/controllers/default.py", line 24, in <module> File "gluon/globals.py", line 101, in <lambda> File "C:/web2py_win(2)/ web2py/applications/images/controllers/default.py", line 6, in showIndexError: list index out of range In file: C:\web2py_win(2)\web2py\applications\images/controllers/ default.py 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25. def index(): images=db().select(db.image.ALL,orderby=db.image.title) return dict(images=images) def show(): images = db(db.image.id == request.args[1]).select() if len(images) < 1: session.flash = T ('No images to show!') image = images[0] return dict() image=db (db.image.id==request.args[0]).select()[0] form=SQLFORM (db.comment,fields=['author','email','body']) form.vars.image_id=image.id if form.accepts(request.vars,session): response.flash='your comment is posted' comments=db (db.comment.image_id==image.id).select() return dict (image=image,comments=comments,form=form) def ============================================== This is the images files showing two records. ====================================== customize me! /images/default/index Authentication LoginRegisterLost PasswordMain Menu IndexEdit This App EditControllerViewLayoutStylesheetDB ModelMenu ModelDatabase images : image.id image.title image.file 2 me and me file 1 me and the shark file Current Images •me and me •me and the shark On Aug 7, 12:07 am, Yarko Tymciurak <yark...@gmail.com> wrote: > did you create an image with the admin interface, as shown on p. 56? > > If you did not, then the select on line 6 would return NO records, and > therefore select()[0] would create an > index out of range. > > You can check / change this by re-writing the select in the show() procedure > to something like this (I have not tried, so it might not be quite right): > > def show(): > images = db(db.image.id == request.args[0]).select() > if len(images) < 1: > session.flash = T('No images to show!') > return dict() > image = images[0] > # the rest as is.... > > Regards, > - Yarko > > > > On Fri, Aug 7, 2009 at 12:54 AM, jayvandal <jayvan...@gmail.com> wrote: > > > Error ticket for "images" > > Ticket 127.0.0.1.2009-08-06.23-39-06.cf3dcbd3-ce73-4175-8d61- > > ff5aca00c066 > > > Hello, > > I am reworking the tutorials in the web2py manual. In this Images > > 3.6 , I am following the code and I am lost atthis point. > > Thanks for any help > > Jim > > > Error traceback > > 1.2.3.4.5.6.7. Traceback (most recent call last): File "gluon/ > > restricted.py", line 178, in restricted File "C:/web2py_win(2)/web2py/ > > applications/images/controllers/default.py", line 19, in <module> > > File "gluon/globals.py", line 101, in <lambda> File "C:/web2py_win(2)/ > > web2py/applications/images/controllers/default.py", line 6, in > > showIndexError: list index out of range > > > In file: C:\web2py_win(2)\web2py\applications\images/controllers/ > > default.py > > 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20. def index(): > > images=db().select(db.image.ALL,orderby=db.image.title) return dict > > (images=images) def show(): image=db(db.image.id==request.args > > [0]).select()[0] form=SQLFORM(db.comment,fields= > > ['author','email','body']) form.vars.image_id=image.id if form.accepts > > (request.vars,session): response.flash='your comment is posted' > > comments=db(db.comment.image_id==image.id).select() return dict > > (image=image,comments=comments,form=form) def download(): import os > > path=os.path.join(request.folder,'uploads',request.args[0]) return > > response.stream(path)response._vars=response._caller(show)- Hide quoted > > text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---