Web2Py Dispatching, URL and my little progress

Thanks to Anthony who replied to my previous post regarding web2py, i read through the chapters about Dispatching and URL again. Although they aren’t very clear in my head but at least, i get the basic format.

I made some modification to my codes as follow:

in default.py i added:

if request.args(0)=='1':

in test.html i added:

<a href = "{{=URL('test', args =['lightstate'], vars = dict(state='1'))}}"><img src ="/Comfort2/static/images/on.jpg" width ="75" height="75"></a>

Web2py Web App - screenshot login

Login page

So i click on the login button, and come to this page. i click on the “on” button and get to this link:

Web2py Web App - screenshot

Turn On

Although it does not remain ON but only repeats the log in- turn on – turn off, i’m glad it did not issue me any error. 😡

I was just wondering is it because i use () instead of [] for request.args(0), i changed it to request.args[0] and it returns me this error right at the first page.

<type ‘exceptions.TypeError’> ‘NoneType’ object has no attribute ‘__getitem__’

okay, due to typo: request.arg[0]

changed to request.args[0] and it returns me:

<type ‘exceptions.IndexError’> list index out of range

Again, Niphlod answered my question in the google group. 🙂 i am so thankful for all the kind people who have responded to my questions and explained so many things to me.

Well then, i’m getting there! Looking forward to more replies and i shall continue tomorrow! 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s