Re: [web2py] Problem passing a json object to controller

2019-11-20 Thread Patito Feo
Javier, 

Tested and not working.

 'builtin_function_or_method' object has no 
attribute '__getitem__'

request.post_vars   


Any ideas?

Thanks for your reply,


El miércoles, 20 de noviembre de 2019, 12:35:38 (UTC-5), Javier Pepe 
escribió:
>
> You need use:
>
>var = json.loads ( request.post_vars.items[*"*json1*"*] )
>
>
> El mié., 20 de nov. de 2019 a la(s) 14:08, Patito Feo (patito...@gmail.com 
> ) escribió:
>
>> Hi,
>>
>> Ive been trying to pass an object with keys to the controller. But i 
>> havent been able to extract the request.vars.
>>
>> Here is my view:
>>
>> var Cars = {}
>> Cars.make = 'Ford';
>> Cars.model = 'Mustang';
>> Cars.year = 1969;
>>
>> $.post( "{{=URL('default', 'transcriptor')}}", //request.post_vars.json1
>>{ 
>>  tarea: 'solicitudguardar', items: { json1: JSON.stringify( Cars 
>> ) }
>>}, )
>>
>>
>> Here is my function:
>>
>> elif request.vars.tarea == 'solicitudguardar':
>>
>>var = json.loads ( request.post_vars.items[json1] )
>>
>>
>>
>> Here is one of the errors i got:
>>
>> global name 'json1' is not defined
>>
>>
>> I dont understand why the array object is not being process as a json 
>> array in controller. 
>>
>> Any help will be much appreciated.
>>
>>
>> Cheers,
>>
>> -- 
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> --- 
>> 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 web...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/cb71d997-01f3-4dd3-b689-35c280e035b7%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/fbcef80d-d1ae-4cae-b22a-5fa10eb5156a%40googlegroups.com.


Re: [web2py] Problem passing a json object to controller

2019-11-20 Thread Javier Pepe
You need use:

   var = json.loads ( request.post_vars.items[*"*json1*"*] )


El mié., 20 de nov. de 2019 a la(s) 14:08, Patito Feo (
patitofeo...@gmail.com) escribió:

> Hi,
>
> Ive been trying to pass an object with keys to the controller. But i
> havent been able to extract the request.vars.
>
> Here is my view:
>
> var Cars = {}
> Cars.make = 'Ford';
> Cars.model = 'Mustang';
> Cars.year = 1969;
>
> $.post( "{{=URL('default', 'transcriptor')}}", //request.post_vars.json1
>{
>  tarea: 'solicitudguardar', items: { json1: JSON.stringify( Cars )
> }
>}, )
>
>
> Here is my function:
>
> elif request.vars.tarea == 'solicitudguardar':
>
>var = json.loads ( request.post_vars.items[json1] )
>
>
>
> Here is one of the errors i got:
>
> global name 'json1' is not defined
>
>
> I dont understand why the array object is not being process as a json
> array in controller.
>
> Any help will be much appreciated.
>
>
> Cheers,
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/cb71d997-01f3-4dd3-b689-35c280e035b7%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAHxJ-7pDW9q03HMwjcOzc6JWovRTLTDTZ3S5o32rYG8JfUb8tw%40mail.gmail.com.


[web2py] Problem passing a json object to controller

2019-11-20 Thread Patito Feo
Hi,

Ive been trying to pass an object with keys to the controller. But i havent 
been able to extract the request.vars.

Here is my view:

var Cars = {}
Cars.make = 'Ford';
Cars.model = 'Mustang';
Cars.year = 1969;

$.post( "{{=URL('default', 'transcriptor')}}", //request.post_vars.json1
   { 
 tarea: 'solicitudguardar', items: { json1: JSON.stringify( Cars ) }
   }, )


Here is my function:

elif request.vars.tarea == 'solicitudguardar':

   var = json.loads ( request.post_vars.items[json1] )
   
   

Here is one of the errors i got:

global name 'json1' is not defined


I dont understand why the array object is not being process as a json array 
in controller. 

Any help will be much appreciated.


Cheers,

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/cb71d997-01f3-4dd3-b689-35c280e035b7%40googlegroups.com.