Its not my day for posting.

request.vars.tabs is a list of strings in python when it gets to the
controller.

The response.json does exactly what its supposed to do.  Sorry for the
spam.

On Dec 30, 12:59 pm, Chris Baron <topher.ba...@gmail.com> wrote:
> In my controller:
>
> def default():
>     f=open('/tmp/debug','w')
>     f.write( str( request.vars.tabs ) )    f.write( '\n' )
>     f.write( response.json(request.vars.tabs) )
>     return dict( tabs = response.json(request.vars.tabs) )
>
> In /tmp/debug
>
> ["{'text': 'Tree List', 'args': {'trees': 'db.tree.id > 0'}, 'plugin':
> 'treeList'}", "{'text': 'Labels', 'args': {'eventInfo': {'labelClick':
> 'selectClade'}}, 'plugin': 'labelPanel'}", "{'text': 'Taxa', 'args':
> {'query': '( db.taxa.id > 0 ) & ( db.node.id == db.taxa.nodeId )',
> 'source': 'table'}, 'plugin': 'taxaPanel'}"]
>
> ["{'text': 'Tree List', 'args': {'trees': 'db.tree.id > 0'}, 'plugin':
> 'treeList'}", "{'text': 'Labels', 'args': {'eventInfo': {'labelClick':
> 'selectClade'}}, 'plugin': 'labelPanel'}", "{'text': 'Taxa', 'args':
> {'query': '( db.taxa.id > 0 ) & ( db.node.id == db.taxa.nodeId )',
> 'source': 'table'}, 'plugin': 'taxaPanel'}"]
>
> In my view :
>
>     <script>
> ...
>     var tabs = eval( "(" + {{response.write(tabs, escape=False)}} +
> ")" );
> ....
>     </script>
>
> It seems that the response.json and simplejson changed with the latest
> upgrade.  Also, It seems to me that the serialization should not have
> inner double quotes and only double quotes at the beginning and ending
> of the string if any at all.
>
> What is the proper way to serialize a python list into json ?

Reply via email to