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 <[email protected]> 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)
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---