On 30 Jul 2013, at 12:22 AM, Niphlod <niph...@gmail.com> wrote:
> can you explain better what's going on ? the generic json view (as any other 
> view) is made to serialize a python object to something (in json's case, a 
> json string). 
> If you already return a string because your code encodes it already, than you 
> don't need any view, because the job the view usually does has been done 
> already by your code.

The explanation isn't quite clear. I believe he's returning a list, intending 
that to be serialized as JSON. But web2py serializes anything that's not a dict 
as a string, so generic.json (for example) is never used.

The question is: what should happen when a controller returns a list? The JSON 
serializer is happy to serialize a list. Is there any downside in doing it? 
Does it make any sense right now for a controller to return a list?

> 
> On Monday, July 29, 2013 11:07:35 PM UTC+2, Matt wrote:
> Hi,
> We're running into an issue with our restful api where a certain method is 
> returning a json string (eg: " ['one', 'two', 'three'] "), however web2py 
> wants to render this as a string even when the request.extension is forced to 
> json, and the response.view is forced to generic.json. I've tracked the issue 
> down to gluon/main.py:231 where it checks if "page" is a dict, and what seems 
> to be happening is that the valid json string above is instead being 
> concatenated as a string representation. Adding this below the check for dict 
> seems to fix it, but I'm not sure how well it fixes the problem:
> 
>     elif isinstance(page, list):
>         response._vars = page
>         run_view_in(response._view_environment)
>         page = response.body.getvalue()
> 
> Any suggestions for other ways to go about fixing this? 
> 
> Thanks,
> Matt
> 


-- 

--- 
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/groups/opt_out.


Reply via email to