On Feb 8, 2011, at 8:03 AM, Massimo Di Pierro wrote:
> 
> I guess the question is... if a variable is not a string or int,
> should it be json.encoded by default?

I don't think so. For one thing, we can't tell on the receiving end if a 
variable should be json-decoded (it's just a string, after all). For another, 
it'd lead to some stunningly ugly (and long) URLs. 

What problem are we really trying to solve?

> 
> On Feb 8, 9:45 am, Jonathan Lundell <[email protected]> wrote:
>> On Feb 8, 2011, at 3:56 AM, Manuele Pesenti wrote:
>> 
>> 
>> 
>>> I'm trying pass some variables from one one controller/function to another 
>>> using the command:
>> 
>>> URL(request.application, 'myControler', 'myFunction', 
>>> vars=dict(myVar=myVar))
>> 
>>> but when I call request.vars.myVar I get a string type object even if myVar 
>>> was a dictionary. I cannot bypass this problem using the json library 
>>> because it causes an early return of the function. I tried:
>> 
>>> import gluon.contrib.simplejson as sj
>> 
>>> myVar = request.vars.myVar
>>> myVar = sj.loads(myVar)
>> 
>>> and after that any command are not executed... any suggestion?
>> 
>> request.vars represents the query string of the URL to be generated, which 
>> must itself be a string. If you want to pass something else in the query 
>> string, it's up to you to make a string of it. You could pass a json-encoded 
>> myVar, for example. URL won't encode it for you, because it has no way of 
>> knowing what kind of encoding the recipient expects.


Reply via email to