Re: [web2py] passing dictionary in URL not working. I Get a string
Do you plan to save the data to the DB or elsewhere at some point? I would suggest putting it in the DB or stuffing it insto session. The JSON thing is more for inter-application communication.
Re: [web2py] passing dictionary in URL not working. I Get a string
Thank you a lot. 2011/7/21 Manuele Pesenti > On 19/07/2011 19:37, António Ramos wrote: > >> So what is the best way to pass a dictionary from one page to the other? >> can i do session.dictvar=mydictvar? >> > > http://docs.python.org/library/json.html > > this is a solution I adopted sometimes... I hope it could be usefull :) > >Manuele >
Re: [web2py] passing dictionary in URL not working. I Get a string
On 19/07/2011 19:37, António Ramos wrote: So what is the best way to pass a dictionary from one page to the other? can i do session.dictvar=mydictvar? http://docs.python.org/library/json.html this is a solution I adopted sometimes... I hope it could be usefull :) Manuele
Re: [web2py] passing dictionary in URL not working. I Get a string
On Jul 19, 2011, at 10:37 AM, António Ramos wrote: > So what is the best way to pass a dictionary from one page to the other? > can i do session.dictvar=mydictvar? Yes, as long as everything you put in there can be pickled. > > thank you > António > > 2011/7/19 Jonathan Lundell > On Jul 19, 2011, at 10:15 AM, António Ramos wrote: > > hello i have this in a view > > > > {{=A(amostra,_href=URL(r=request,c='amostra',f='get',vars={'amostra':amostra,'amostra_detalhe':Amostra[amostra]}))}} > > > > Amostra is a dictionary > > amostra is every element in Amostra > > every amostra of Amostra is a dictionary > > > > > > in this view i iterate over Amostra[amostra]['param1paramN], etc with > > no problem. > > > > > > in the controler amostra, function get i do > > > > print type(request.vars['amostra_detalhe']) > > > > and i get <'str'> and not <'dict'> > > > > what the hell, > > this way i cannot iterate over the params and get this error > > string indices must be integers > > request.vars is simply a representation of a URL query string, which is a > collection of key=value items, where key and value are both treated as > strings. > > You could presumably encode a dict into a string and decode it when it comes > back, but you'll have to do that yourself (and the URL will be pretty ugly). > > > > > > > Please help me.i´m stuck > > thank you > > > > António > > >
Re: [web2py] passing dictionary in URL not working. I Get a string
So what is the best way to pass a dictionary from one page to the other? can i do session.dictvar=mydictvar? thank you António 2011/7/19 Jonathan Lundell > On Jul 19, 2011, at 10:15 AM, António Ramos wrote: > > hello i have this in a view > > > > > {{=A(amostra,_href=URL(r=request,c='amostra',f='get',vars={'amostra':amostra,'amostra_detalhe':Amostra[amostra]}))}} > > > > Amostra is a dictionary > > amostra is every element in Amostra > > every amostra of Amostra is a dictionary > > > > > > in this view i iterate over Amostra[amostra]['param1paramN], etc with > no problem. > > > > > > in the controler amostra, function get i do > > > > print type(request.vars['amostra_detalhe']) > > > > and i get <'str'> and not <'dict'> > > > > what the hell, > > this way i cannot iterate over the params and get this error > > string indices must be integers > > request.vars is simply a representation of a URL query string, which is a > collection of key=value items, where key and value are both treated as > strings. > > You could presumably encode a dict into a string and decode it when it > comes back, but you'll have to do that yourself (and the URL will be pretty > ugly). > > > > > > > Please help me.i´m stuck > > thank you > > > > António > > >
Re: [web2py] passing dictionary in URL not working. I Get a string
On Jul 19, 2011, at 10:15 AM, António Ramos wrote: > hello i have this in a view > > {{=A(amostra,_href=URL(r=request,c='amostra',f='get',vars={'amostra':amostra,'amostra_detalhe':Amostra[amostra]}))}} > > > Amostra is a dictionary > amostra is every element in Amostra > every amostra of Amostra is a dictionary > > > in this view i iterate over Amostra[amostra]['param1paramN], etc with no > problem. > > > in the controler amostra, function get i do > > print type(request.vars['amostra_detalhe']) > > and i get <'str'> and not <'dict'> > > what the hell, > this way i cannot iterate over the params and get this error > string indices must be integers request.vars is simply a representation of a URL query string, which is a collection of key=value items, where key and value are both treated as strings. You could presumably encode a dict into a string and decode it when it comes back, but you'll have to do that yourself (and the URL will be pretty ugly). > > > Please help me.i´m stuck > thank you > > António
[web2py] passing dictionary in URL not working. I Get a string
hello i have this in a view {{=A(amostra,_href=URL(r=request,*c='amostra',f='get',* vars={'amostra':amostra,*'amostra_detalhe':Amostra[amostra]*}))}} Amostra is a dictionary amostra is every element in Amostra every amostra of Amostra is a dictionary in this view i iterate over Amostra[amostra]['param1paramN], etc with no problem. in the controler *amostra*, function *get* i do print type(request.vars['amostra_detalhe']) and i get <'str'> and not <'dict'> what the hell, this way i cannot iterate over the params and get this error *string indices must be integers* Please help me.i´m stuck thank you António