found a solution, 

using ast.literal_eval 

data = request.get_args['_data']
print data
## OUT: ["{"year": 2013, "jan": 50, "feb": 60}", "{"year": 2012, "jan": 40, 
"feb": 30}"] ##
print ast.literal_eval(data[0])
## OUT: {"year": 2013, "jan": 50, "feb": 60} ## <- class: dict

so with a simple for loop i am creating a new list with dicts inside 
instead of strings!

nevertheless i think that this is not the proper way to handle all this, 
and i should return a json result from the function instead (or something 
like that)

comments/suggestions much appreciated! 

On Wednesday, July 31, 2013 1:01:23 PM UTC+3, Antonis Konstantinos Tzorvas 
wrote:
>
> I have created a function which returns from a given url some info parsed 
> from the file in the url
>
> http://url/file.txt
> and it returns something like this
>
> parser.py output:
> _name: Test1
> _data: [{"year": 2013, "jan": 50, "feb": 60}, {"year": 2012, "jan": 40, 
> "feb": 30}]
>
> def add():
>   ..
>   item = parser(form.vars.url)
>   redirect(URL('confirm', vars=vars(item)))
>   ..
>
> in confirm()
>
> if i do `print request.get_vars['_data'].__class__`
> the result is a list
>
> if i do `print request.get_vars['_data'][0].__class__`
> the result is a string and its something like this: ["{"year": 2013, 
> "jan": 50, "feb": 60}", "{"year": 2012, "jan": 40, "feb": 30}"], 
> but i have to transform it back into dict so to proceed with the 
> db.table.insert
>
> any idea on how to handle this?
>

-- 

--- 
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