Just to add a bit...
and if using vars:
>>
>> <a href = "{{=URL('test', vars = dict(bulb='1', state='on' ))}}"><img
>> src ="/Comfort2/static/images/on.jpg" width ="75" height="75"></a> ?
>>
>> if request.vars ={'bulb':1, 'state' :on}
>>
>
Note that in Python, to test equality you use "==", not just a single "="
(which is used for assignment only). Also, note that request.vars (and
request itself) is a gluon.storage.Storage object, not a dict (though it
inherits from dict and you can in fact test equality with a dict as above).
See http://web2py.com/books/default/chapter/29/04#request (response and
session are Storage objects as well). request.args is a gluon.storage.List
object, which inherits from list.
In the generic view there's included "response toolbar" that you can use to
> "inspect" what's going on (e.g., what request.args is specifically)
> Or, if you have a view already, include at the top
> {{=response.toolbar()}}
> to show it.
>
You can also show just the args and vars in your view via:
{{=request.args}}
{{=request.vars}}
> And all the above are in the same function 'test', so can i omit 'test' in
>> the URL?
>>
>
web2py needs the application, controller, and function in the URL to know
where to route the request, though you can eliminate a default application,
controller, and function if desired by properly specifying the routing --
see http://web2py.com/books/default/chapter/29/04#URL-rewrite for details.
Even in that case, though, you would still use the URL() function in the
same way -- it will automatically take into account any custom routing
specified.
If you want to see what the URL() function generates, I recommend starting
a web2py shell and trying it there. For a shell:
python web2py.py -S yourapp -M
(The -M tells it to execute the model files for the app -- you'll be in a
Python shell with the full web2py environment as well as the models for
your app.)
Anthony
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.