I am not sure what you mean by:

for entry in decoded['config_templates']:
        return entry['name']

why do you have a return in a loop? It will only return the first time. The 
cli may do something unusual.


On Friday, 18 July 2014 16:15:11 UTC-5, Sif Baksh wrote:
>
>
> My very first besides the Hello World.
> It's pulling data from a RESTful Server and the output is JSON.
> We have 52 entries in our Config Templates and it just prints out one 
> under web2py.
>
> When I run this in web2py it only return one result:
>
> def index():
>
>     import requests
>     import json
>     url = "https://10.10.10.1/wapi/2/";
>     object_type = "config_templates/search"
>     data = requests.get(url + object_type, verify=False, auth=('myuser', 
> 'mypwd'))
>     json_input = data.text
>     try:
>         decoded = json.loads(json_input)
>     for entry in decoded['config_templates']:
>         return entry['name']
>     except (ValueError, KeyError, TypeError):
>         return "JSON format error"
>
>
> When I run the following from the cli it returns 52 entries:
>
>     import requests
>     import json
>     url = "https://10.10.10.1/wapi/2/";
>     object_type = "config_templates/search"
>     data = requests.get(url + object_type, verify=False, auth=('myuser', 
> 'mypwd'))
>     json_input = data.text
>     try:
>         decoded = json.loads(json_input)
>     for entry in decoded['config_templates']:
>         return entry['name']
>     except (ValueError, KeyError, TypeError):
>         return "JSON format error"
>
> Do I need to do something different in web2py?
>
> Thanks in advance
> Sif
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to