In this specific case, db.select returned with no rows and hence when you
tried to access row 0, it gave index error.
Suhas Patil.
On Wednesday, February 25, 2015 at 1:59:46 AM UTC+5:30, tensio wrote:
>
> Hi Guys,
>
> currently I'm working on a website with web.py and today I found an
> strange error.
> postdata = db.select("blog_article", where="id=$titleid", vars=locals())
> postdata = postdata[0]
> if title == postdata.titel:
>
> I get this error:
>
> File "app.py", line 163, in GET
>
> postdata = postdata[0]
>
> File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/web/utils.py",
>
> line 684, in __getitem__
>
> raise IndexError, str(i)
>
> IndexError: 0
>
> So it seems to be a problem with the [0] thing. But I use the same code
> for another db call:
> user = db.select('user', where="id=$userid", vars=locals())[0]
> where I get no error at all.
>
> The funny thing is, with the postdata[0] thing I get my desired result,
> but I keep getting the error.
> What is wrong?
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.