Re: [web2py] Decode string

2016-08-19 Thread Richard Vézina
No clue...

On Fri, Aug 19, 2016 at 9:49 AM, António Ramos  wrote:

> Its a Post request to my controller. they are not in the url ( I think...)
>
> 2016-08-19 14:34 GMT+01:00 Richard Vézina :
>
>> if you pass json through url to have to parse the string json dump...
>>
>> Richard
>>
>> On Fri, Aug 19, 2016 at 9:27 AM, António Ramos 
>> wrote:
>>
>>> I have started another thread called
>>> How does web2py save JSON fields?
>>>
>>> because i think its the json field that is messing my data on save
>>>
>>> thank you
>>>
>>> 2016-08-19 14:03 GMT+01:00 Richard Vézina :
>>>
 You have to URL unquote not request.vars http://stacko
 verflow.com/questions/16566069/url-decode-utf-8-in-python

 If you do request.vars.yourvarname what do you have?

 You can try request.vars.yourvarname.decode('utf-8')


 Richard


 On Thu, Aug 18, 2016 at 7:24 PM, António Ramos 
 wrote:

> Sorry to insist but cant find any clue.
> I tried a simple http post from fiddler or postman
>
> i sent a Post  to my controller with
> Content-Type: application/json; charset=utf-8
> and in the body
> {"Sistema de Gestão da Qualidade":1,"b":2}
>
> and i get in request.vars
> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 1, 'b': 2}
>
> How do i get "Sistema de Gestão da Qualidade" from the request.vars?
>
> Regards
> António
>
>
>
> 2016-08-18 19:49 GMT+01:00 Richard Vézina  >:
>
>> I think it url encoded... Search google about it, it should be
>> obvious then...
>>
>> Richard
>>
>> On Thu, Aug 18, 2016 at 2:12 PM, António Ramos 
>> wrote:
>>
>>> Im getting this data on request.vars from Google forms onsubmit
>>> event.
>>>
>>> u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00'
>>>
>>> how do i convert it to
>>> "Sistema de Gestão da Qualidade"
>>>
>>> i tried urllib.unquote(x).decode('utf-8')  in my controller
>>> def getit():
>>> ret={}
>>> for x in request.vars:
>>> temp=urllib.unquote(x).decode("utf-8")
>>> ret[x]=request.vars[x];
>>> db.responses.insert(allresponses=ret)
>>> but my responses.allreponses document is saved as the same value
>>> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00':
>>> 'testing'}
>>> Allresponses field is a JSON Field
>>>
>>>
>>>
>>> Regards
>>> António
>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

 --
 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.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> Resources:
>>> - http://web2py.com
>>> - http://web2py.com/book 

Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread António Ramos
I decided to "stick" without the json field... too much code/decode
envolved  and the json will grow very big. In the admin will be a mess...

Thank you all and forget it! :P


2016-08-19 16:36 GMT+01:00 António Ramos :

>
> [image: Imagem inline 1]
>
> 2016-08-19 16:26 GMT+01:00 Marlysson Silva :
>
>> In a view.json? weired..
>>
>> Em sexta-feira, 19 de agosto de 2016 12:24:23 UTC-3, Ramos escreveu:
>>>
>>> Instead of "Gestão" i get this when rendering with BEAUTIFY(row) being
>>> row=db.responses[my_ID]
>>> allresponses :
>>> Gsãcn : 1
>>> delete_record : 
>>> f1 :
>>> id : 99L
>>> update_record : 
>>>
>>> 2016-08-19 16:18 GMT+01:00 Marlysson Silva :
>>>
 For test, try render the controller data in a generic_view.json .. to
 test whether the encode the page which it's wrong..

 Em sexta-feira, 19 de agosto de 2016 12:07:27 UTC-3, Ramos escreveu:
>
> yes i remove the unquote and saved request.vars directly.
>
> Also went to admin and by hand created a new record with
>
> {"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn':
> 1}
>
> so far so good , i understand now that saving in json fields encodes
> the data.
> Now i need to read that data and decode it.
>
> Regards
> António
>
> 2016-08-19 16:03 GMT+01:00 Marlysson Silva :
>
>> You removed the urllib.uquote() ? And after just receiving the
>> request directly..
>>
>> Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>>>
>>> Ok got it.
>>> If i create a new record via admin with
>>>
>>> {"Gestão":1} in the json Field, after saving the new record i get it
>>> as
>>>
>>> {u'Gs\xe3\x00cn': 1}
>>>
>>> You said its utf-8 encoded
>>> How do i decode it again to "Gestão" ?
>>> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>>>
>>> sorry and thank you for your time.
>>>
>>> António
>>>
>>>
>>> 2016-08-19 15:16 GMT+01:00 Niphlod :
>>>
 why don't you just pass request.vars without quoting and unquoting
 
 anyway, json is always utf-8 encoded. that's the difference you're
 seeing.


 On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>
> Hi,im starting a new post because i found that JSON fields change
> data as they are saved.
> So repeating again the problem posted before
>
>
> My model
> db.define_table('responses',
> Field('f1'),
> Field('allresponses','json'))
>
> My controller
> def getit():
> ret={}
> for x in request.vars:
>db.responses.insert(f1=urllib.unquote(x))
>ret[urllib.unquote(x)]=request.vars[x];
> db.responses.insert(allresponses=ret)
>
> i get in my request.vars
>
> {'Timestamp': '8/19/2016 9:54:44', 
> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade':
> 'sss'}
>
> after executing the controller code,when i look at  table
> responses i see in allresponses field
> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00
> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>
> but field f1 is correct
> "Sistema de Gestão de Qualidade"
>
> So how can i deal with this?
> This is just a test but i will get many keys in request vars and
> so a json field would be better but need to solve this issue.
>
> Regards
> António
>
> --
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>> 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+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
 Resources:
 - http://web2py.com
 - 

Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread António Ramos
[image: Imagem inline 1]

2016-08-19 16:26 GMT+01:00 Marlysson Silva :

> In a view.json? weired..
>
> Em sexta-feira, 19 de agosto de 2016 12:24:23 UTC-3, Ramos escreveu:
>>
>> Instead of "Gestão" i get this when rendering with BEAUTIFY(row) being
>> row=db.responses[my_ID]
>> allresponses :
>> Gsãcn : 1
>> delete_record : 
>> f1 :
>> id : 99L
>> update_record : 
>>
>> 2016-08-19 16:18 GMT+01:00 Marlysson Silva :
>>
>>> For test, try render the controller data in a generic_view.json .. to
>>> test whether the encode the page which it's wrong..
>>>
>>> Em sexta-feira, 19 de agosto de 2016 12:07:27 UTC-3, Ramos escreveu:

 yes i remove the unquote and saved request.vars directly.

 Also went to admin and by hand created a new record with

 {"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1}

 so far so good , i understand now that saving in json fields encodes
 the data.
 Now i need to read that data and decode it.

 Regards
 António

 2016-08-19 16:03 GMT+01:00 Marlysson Silva :

> You removed the urllib.uquote() ? And after just receiving the request
> directly..
>
> Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>>
>> Ok got it.
>> If i create a new record via admin with
>>
>> {"Gestão":1} in the json Field, after saving the new record i get it
>> as
>>
>> {u'Gs\xe3\x00cn': 1}
>>
>> You said its utf-8 encoded
>> How do i decode it again to "Gestão" ?
>> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>>
>> sorry and thank you for your time.
>>
>> António
>>
>>
>> 2016-08-19 15:16 GMT+01:00 Niphlod :
>>
>>> why don't you just pass request.vars without quoting and unquoting
>>> 
>>> anyway, json is always utf-8 encoded. that's the difference you're
>>> seeing.
>>>
>>>
>>> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:

 Hi,im starting a new post because i found that JSON fields change
 data as they are saved.
 So repeating again the problem posted before


 My model
 db.define_table('responses',
 Field('f1'),
 Field('allresponses','json'))

 My controller
 def getit():
 ret={}
 for x in request.vars:
db.responses.insert(f1=urllib.unquote(x))
ret[urllib.unquote(x)]=request.vars[x];
 db.responses.insert(allresponses=ret)

 i get in my request.vars

 {'Timestamp': '8/19/2016 9:54:44', 
 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade':
 'sss'}

 after executing the controller code,when i look at  table
 responses i see in allresponses field
 {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00
 \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}

 but field f1 is correct
 "Sistema de Gestão de Qualidade"

 So how can i deal with this?
 This is just a test but i will get many keys in request vars and so
 a json field would be better but need to solve this issue.

 Regards
 António

 --
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 --
>>> 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+un...@googlegroups.com.
>>> For 

Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread Marlysson Silva
In a view.json? weired..

Em sexta-feira, 19 de agosto de 2016 12:24:23 UTC-3, Ramos escreveu:
>
> Instead of "Gestão" i get this when rendering with BEAUTIFY(row) being 
> row=db.responses[my_ID]
> allresponses : 
> Gsãcn : 1
> delete_record : 
> f1 : 
> id : 99L
> update_record : 
>
> 2016-08-19 16:18 GMT+01:00 Marlysson Silva  >:
>
>> For test, try render the controller data in a generic_view.json .. to 
>> test whether the encode the page which it's wrong..
>>
>> Em sexta-feira, 19 de agosto de 2016 12:07:27 UTC-3, Ramos escreveu:
>>>
>>> yes i remove the unquote and saved request.vars directly.
>>>
>>> Also went to admin and by hand created a new record with
>>>
>>> {"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1}
>>>
>>> so far so good , i understand now that saving in json fields encodes the 
>>> data.
>>> Now i need to read that data and decode it.
>>>
>>> Regards
>>> António
>>>
>>> 2016-08-19 16:03 GMT+01:00 Marlysson Silva :
>>>
 You removed the urllib.uquote() ? And after just receiving the request 
 directly..

 Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>
> Ok got it.
> If i create a new record via admin with
>
> {"Gestão":1} in the json Field, after saving the new record i get it as
>
> {u'Gs\xe3\x00cn': 1}
>
> You said its utf-8 encoded 
> How do i decode it again to "Gestão" ?
> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>
> sorry and thank you for your time.
>
> António
>
>
> 2016-08-19 15:16 GMT+01:00 Niphlod :
>
>> why don't you just pass request.vars without quoting and unquoting 
>> 
>> anyway, json is always utf-8 encoded. that's the difference you're 
>> seeing.
>>
>>
>> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>>>
>>> Hi,im starting a new post because i found that JSON fields change 
>>> data as they are saved.
>>> So repeating again the problem posted before
>>>
>>>
>>> My model
>>> db.define_table('responses',
>>> Field('f1'),
>>> Field('allresponses','json'))
>>>
>>> My controller
>>> def getit():
>>> ret={}
>>> for x in request.vars:
>>>db.responses.insert(f1=urllib.unquote(x))
>>>ret[urllib.unquote(x)]=request.vars[x];
>>> db.responses.insert(allresponses=ret)
>>>
>>> i get in my request.vars
>>>
>>> {'Timestamp': '8/19/2016 9:54:44', 
>>> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}
>>>
>>> after executing the controller code,when i look at  table responses 
>>> i see in allresponses field
>>> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 
>>> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>>>
>>> but field f1 is correct
>>> "Sistema de Gestão de Qualidade"
>>>
>>> So how can i deal with this?
>>> This is just a test but i will get many keys in request vars and so 
>>> a json field would be better but need to solve this issue.
>>>
>>> Regards
>>> António
>>>
>>> -- 
>> 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+un...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> -- 
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- 

Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread António Ramos
Instead of "Gestão" i get this when rendering with BEAUTIFY(row) being
row=db.responses[my_ID]
allresponses :
Gsãcn : 1
delete_record : 
f1 :
id : 99L
update_record : 

2016-08-19 16:18 GMT+01:00 Marlysson Silva :

> For test, try render the controller data in a generic_view.json .. to test
> whether the encode the page which it's wrong..
>
> Em sexta-feira, 19 de agosto de 2016 12:07:27 UTC-3, Ramos escreveu:
>>
>> yes i remove the unquote and saved request.vars directly.
>>
>> Also went to admin and by hand created a new record with
>>
>> {"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1}
>>
>> so far so good , i understand now that saving in json fields encodes the
>> data.
>> Now i need to read that data and decode it.
>>
>> Regards
>> António
>>
>> 2016-08-19 16:03 GMT+01:00 Marlysson Silva :
>>
>>> You removed the urllib.uquote() ? And after just receiving the request
>>> directly..
>>>
>>> Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:

 Ok got it.
 If i create a new record via admin with

 {"Gestão":1} in the json Field, after saving the new record i get it as

 {u'Gs\xe3\x00cn': 1}

 You said its utf-8 encoded
 How do i decode it again to "Gestão" ?
 u'Gs\xe3\x00cn'.decode('utf-8') does not work..

 sorry and thank you for your time.

 António


 2016-08-19 15:16 GMT+01:00 Niphlod :

> why don't you just pass request.vars without quoting and unquoting 
> anyway, json is always utf-8 encoded. that's the difference you're
> seeing.
>
>
> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>>
>> Hi,im starting a new post because i found that JSON fields change
>> data as they are saved.
>> So repeating again the problem posted before
>>
>>
>> My model
>> db.define_table('responses',
>> Field('f1'),
>> Field('allresponses','json'))
>>
>> My controller
>> def getit():
>> ret={}
>> for x in request.vars:
>>db.responses.insert(f1=urllib.unquote(x))
>>ret[urllib.unquote(x)]=request.vars[x];
>> db.responses.insert(allresponses=ret)
>>
>> i get in my request.vars
>>
>> {'Timestamp': '8/19/2016 9:54:44', 
>> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade':
>> 'sss'}
>>
>> after executing the controller code,when i look at  table responses
>> i see in allresponses field
>> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00
>> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>>
>> but field f1 is correct
>> "Sistema de Gestão de Qualidade"
>>
>> So how can i deal with this?
>> This is just a test but i will get many keys in request vars and so a
>> json field would be better but need to solve this issue.
>>
>> Regards
>> António
>>
>> --
> 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+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

 --
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit 

[web2py] Re: New to web2py. Template use cases

2016-08-19 Thread Marlysson Silva
Massimo I saw within template.py and he have a import to a external file ( 
_compat.py ) it's get just template.py, really?

Em quinta-feira, 18 de agosto de 2016 16:37:47 UTC-3, Massimo Di Pierro 
escreveu:
>
> Or simply copy the gluon/template.py where you want it, import it, than 
> from template import render, etc.
>
> On Wednesday, 17 August 2016 06:28:05 UTC-5, Marlysson Silva wrote:
>>
>> You are importing starting of gluon or just file template.py from gluon?
>> Based in documentation you have just import standalone file template.py 
>> from gluon :| .
>>
>> Em terça-feira, 16 de agosto de 2016 20:51:04 UTC-3, billy...@gmail.com 
>> escreveu:
>>>
>>> Coming trying out different framework and really love web2py. The 
>>> template language is very simple. how do I use it in different framework?
>>>
>>> Trying to replace jinja2 template with web2py template.
>>>
>>> import template seem to doesn't work with default jinja2 template 
>>> language the framework assumes.
>>>  
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: New to web2py. Template use cases

2016-08-19 Thread Marlysson Silva
Massimo I saw within template.py and he have a import to a external file ( 
_compac.py ) it's get just template.py, really?

Em sexta-feira, 19 de agosto de 2016 12:18:02 UTC-3, billy...@gmail.com 
escreveu:
>
> I get warning: root: unable to import plural rules: no module named 
> plural_rules and it breaks.
>
> On Thursday, August 18, 2016 at 3:37:47 PM UTC-4, Massimo Di Pierro wrote:
>>
>> Or simply copy the gluon/template.py where you want it, import it, than 
>> from template import render, etc.
>>
>> On Wednesday, 17 August 2016 06:28:05 UTC-5, Marlysson Silva wrote:
>>>
>>> You are importing starting of gluon or just file template.py from gluon?
>>> Based in documentation you have just import standalone file template.py 
>>> from gluon :| .
>>>
>>> Em terça-feira, 16 de agosto de 2016 20:51:04 UTC-3, billy...@gmail.com 
>>> escreveu:

 Coming trying out different framework and really love web2py. The 
 template language is very simple. how do I use it in different framework?

 Trying to replace jinja2 template with web2py template.

 import template seem to doesn't work with default jinja2 template 
 language the framework assumes.
  

>>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread Marlysson Silva
For test, try render the controller data in a generic_view.json .. to test 
whether the encode the page which it's wrong..

Em sexta-feira, 19 de agosto de 2016 12:07:27 UTC-3, Ramos escreveu:
>
> yes i remove the unquote and saved request.vars directly.
>
> Also went to admin and by hand created a new record with
>
> {"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1}
>
> so far so good , i understand now that saving in json fields encodes the 
> data.
> Now i need to read that data and decode it.
>
> Regards
> António
>
> 2016-08-19 16:03 GMT+01:00 Marlysson Silva  >:
>
>> You removed the urllib.uquote() ? And after just receiving the request 
>> directly..
>>
>> Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>>>
>>> Ok got it.
>>> If i create a new record via admin with
>>>
>>> {"Gestão":1} in the json Field, after saving the new record i get it as
>>>
>>> {u'Gs\xe3\x00cn': 1}
>>>
>>> You said its utf-8 encoded 
>>> How do i decode it again to "Gestão" ?
>>> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>>>
>>> sorry and thank you for your time.
>>>
>>> António
>>>
>>>
>>> 2016-08-19 15:16 GMT+01:00 Niphlod :
>>>
 why don't you just pass request.vars without quoting and unquoting 
 anyway, json is always utf-8 encoded. that's the difference you're 
 seeing.


 On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>
> Hi,im starting a new post because i found that JSON fields change data 
> as they are saved.
> So repeating again the problem posted before
>
>
> My model
> db.define_table('responses',
> Field('f1'),
> Field('allresponses','json'))
>
> My controller
> def getit():
> ret={}
> for x in request.vars:
>db.responses.insert(f1=urllib.unquote(x))
>ret[urllib.unquote(x)]=request.vars[x];
> db.responses.insert(allresponses=ret)
>
> i get in my request.vars
>
> {'Timestamp': '8/19/2016 9:54:44', 
> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}
>
> after executing the controller code,when i look at  table responses i 
> see in allresponses field
> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 
> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>
> but field f1 is correct
> "Sistema de Gestão de Qualidade"
>
> So how can i deal with this?
> This is just a test but i will get many keys in request vars and so a 
> json field would be better but need to solve this issue.
>
> Regards
> António
>
> -- 
 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+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: New to web2py. Template use cases

2016-08-19 Thread billyhun01
I get warning: root: unable to import plural rules: no module named 
plural_rules and it breaks.

On Thursday, August 18, 2016 at 3:37:47 PM UTC-4, Massimo Di Pierro wrote:
>
> Or simply copy the gluon/template.py where you want it, import it, than 
> from template import render, etc.
>
> On Wednesday, 17 August 2016 06:28:05 UTC-5, Marlysson Silva wrote:
>>
>> You are importing starting of gluon or just file template.py from gluon?
>> Based in documentation you have just import standalone file template.py 
>> from gluon :| .
>>
>> Em terça-feira, 16 de agosto de 2016 20:51:04 UTC-3, billy...@gmail.com 
>> escreveu:
>>>
>>> Coming trying out different framework and really love web2py. The 
>>> template language is very simple. how do I use it in different framework?
>>>
>>> Trying to replace jinja2 template with web2py template.
>>>
>>> import template seem to doesn't work with default jinja2 template 
>>> language the framework assumes.
>>>  
>>>
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread António Ramos
yes i remove the unquote and saved request.vars directly.

Also went to admin and by hand created a new record with

{"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1}

so far so good , i understand now that saving in json fields encodes the
data.
Now i need to read that data and decode it.

Regards
António

2016-08-19 16:03 GMT+01:00 Marlysson Silva :

> You removed the urllib.uquote() ? And after just receiving the request
> directly..
>
> Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>>
>> Ok got it.
>> If i create a new record via admin with
>>
>> {"Gestão":1} in the json Field, after saving the new record i get it as
>>
>> {u'Gs\xe3\x00cn': 1}
>>
>> You said its utf-8 encoded
>> How do i decode it again to "Gestão" ?
>> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>>
>> sorry and thank you for your time.
>>
>> António
>>
>>
>> 2016-08-19 15:16 GMT+01:00 Niphlod :
>>
>>> why don't you just pass request.vars without quoting and unquoting 
>>> anyway, json is always utf-8 encoded. that's the difference you're
>>> seeing.
>>>
>>>
>>> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:

 Hi,im starting a new post because i found that JSON fields change data
 as they are saved.
 So repeating again the problem posted before


 My model
 db.define_table('responses',
 Field('f1'),
 Field('allresponses','json'))

 My controller
 def getit():
 ret={}
 for x in request.vars:
db.responses.insert(f1=urllib.unquote(x))
ret[urllib.unquote(x)]=request.vars[x];
 db.responses.insert(allresponses=ret)

 i get in my request.vars

 {'Timestamp': '8/19/2016 9:54:44', 
 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade':
 'sss'}

 after executing the controller code,when i look at  table responses i
 see in allresponses field
 {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00
 \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}

 but field f1 is correct
 "Sistema de Gestão de Qualidade"

 So how can i deal with this?
 This is just a test but i will get many keys in request vars and so a
 json field would be better but need to solve this issue.

 Regards
 António

 --
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread Marlysson Silva
You removed the urllib.uquote() ? And after just receiving the request 
directly..

Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu:
>
> Ok got it.
> If i create a new record via admin with
>
> {"Gestão":1} in the json Field, after saving the new record i get it as
>
> {u'Gs\xe3\x00cn': 1}
>
> You said its utf-8 encoded 
> How do i decode it again to "Gestão" ?
> u'Gs\xe3\x00cn'.decode('utf-8') does not work..
>
> sorry and thank you for your time.
>
> António
>
>
> 2016-08-19 15:16 GMT+01:00 Niphlod :
>
>> why don't you just pass request.vars without quoting and unquoting 
>> anyway, json is always utf-8 encoded. that's the difference you're seeing.
>>
>>
>> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>>>
>>> Hi,im starting a new post because i found that JSON fields change data 
>>> as they are saved.
>>> So repeating again the problem posted before
>>>
>>>
>>> My model
>>> db.define_table('responses',
>>> Field('f1'),
>>> Field('allresponses','json'))
>>>
>>> My controller
>>> def getit():
>>> ret={}
>>> for x in request.vars:
>>>db.responses.insert(f1=urllib.unquote(x))
>>>ret[urllib.unquote(x)]=request.vars[x];
>>> db.responses.insert(allresponses=ret)
>>>
>>> i get in my request.vars
>>>
>>> {'Timestamp': '8/19/2016 9:54:44', 
>>> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}
>>>
>>> after executing the controller code,when i look at  table responses i 
>>> see in allresponses field
>>> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 
>>> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>>>
>>> but field f1 is correct
>>> "Sistema de Gestão de Qualidade"
>>>
>>> So how can i deal with this?
>>> This is just a test but i will get many keys in request vars and so a 
>>> json field would be better but need to solve this issue.
>>>
>>> Regards
>>> António
>>>
>>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread António Ramos
Ok got it.
If i create a new record via admin with

{"Gestão":1} in the json Field, after saving the new record i get it as

{u'Gs\xe3\x00cn': 1}

You said its utf-8 encoded
How do i decode it again to "Gestão" ?
u'Gs\xe3\x00cn'.decode('utf-8') does not work..

sorry and thank you for your time.

António


2016-08-19 15:16 GMT+01:00 Niphlod :

> why don't you just pass request.vars without quoting and unquoting 
> anyway, json is always utf-8 encoded. that's the difference you're seeing.
>
>
> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>>
>> Hi,im starting a new post because i found that JSON fields change data as
>> they are saved.
>> So repeating again the problem posted before
>>
>>
>> My model
>> db.define_table('responses',
>> Field('f1'),
>> Field('allresponses','json'))
>>
>> My controller
>> def getit():
>> ret={}
>> for x in request.vars:
>>db.responses.insert(f1=urllib.unquote(x))
>>ret[urllib.unquote(x)]=request.vars[x];
>> db.responses.insert(allresponses=ret)
>>
>> i get in my request.vars
>>
>> {'Timestamp': '8/19/2016 9:54:44', 
>> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade':
>> 'sss'}
>>
>> after executing the controller code,when i look at  table responses i
>> see in allresponses field
>> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00
>> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>>
>> but field f1 is correct
>> "Sistema de Gestão de Qualidade"
>>
>> So how can i deal with this?
>> This is just a test but i will get many keys in request vars and so a
>> json field would be better but need to solve this issue.
>>
>> Regards
>> António
>>
>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] LDAP authentication and user creation

2016-08-19 Thread Marvi Benedet
Hello to all.
I tried LDAP authentication and all work flawless.

As an user logs in, the relative user entry is created in the web2py user
table. That's great.

But sometimes it would be usefull to have the user in the table before his
first login.

So, would be great for some user, says an administrator, to have a form
where he can insert the username of a generic user, web2py checks if the
user exists in the LDAP server and then add him in the web2py table.

is there a way?

I'm creating a sort of inventory application for our company.  So I would
like, for the administrator of the inventory, to associate a good to a
collegue that maybe hasn't yet logged in the system.

Thanks, Marvi

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: How does web2py save JSON fields?

2016-08-19 Thread Niphlod
why don't you just pass request.vars without quoting and unquoting 
anyway, json is always utf-8 encoded. that's the difference you're seeing.

On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote:
>
> Hi,im starting a new post because i found that JSON fields change data as 
> they are saved.
> So repeating again the problem posted before
>
>
> My model
> db.define_table('responses',
> Field('f1'),
> Field('allresponses','json'))
>
> My controller
> def getit():
> ret={}
> for x in request.vars:
>db.responses.insert(f1=urllib.unquote(x))
>ret[urllib.unquote(x)]=request.vars[x];
> db.responses.insert(allresponses=ret)
>
> i get in my request.vars
>
> {'Timestamp': '8/19/2016 9:54:44', 
> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}
>
> after executing the controller code,when i look at  table responses i see 
> in allresponses field
> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 
> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'}
>
> but field f1 is correct
> "Sistema de Gestão de Qualidade"
>
> So how can i deal with this?
> This is just a test but i will get many keys in request vars and so a json 
> field would be better but need to solve this issue.
>
> Regards
> António
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Decode string

2016-08-19 Thread António Ramos
Its a Post request to my controller. they are not in the url ( I think...)

2016-08-19 14:34 GMT+01:00 Richard Vézina :

> if you pass json through url to have to parse the string json dump...
>
> Richard
>
> On Fri, Aug 19, 2016 at 9:27 AM, António Ramos 
> wrote:
>
>> I have started another thread called
>> How does web2py save JSON fields?
>>
>> because i think its the json field that is messing my data on save
>>
>> thank you
>>
>> 2016-08-19 14:03 GMT+01:00 Richard Vézina :
>>
>>> You have to URL unquote not request.vars http://stacko
>>> verflow.com/questions/16566069/url-decode-utf-8-in-python
>>>
>>> If you do request.vars.yourvarname what do you have?
>>>
>>> You can try request.vars.yourvarname.decode('utf-8')
>>>
>>>
>>> Richard
>>>
>>>
>>> On Thu, Aug 18, 2016 at 7:24 PM, António Ramos 
>>> wrote:
>>>
 Sorry to insist but cant find any clue.
 I tried a simple http post from fiddler or postman

 i sent a Post  to my controller with
 Content-Type: application/json; charset=utf-8
 and in the body
 {"Sistema de Gestão da Qualidade":1,"b":2}

 and i get in request.vars
 {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 1, 'b': 2}

 How do i get "Sistema de Gestão da Qualidade" from the request.vars?

 Regards
 António



 2016-08-18 19:49 GMT+01:00 Richard Vézina 
 :

> I think it url encoded... Search google about it, it should be obvious
> then...
>
> Richard
>
> On Thu, Aug 18, 2016 at 2:12 PM, António Ramos 
> wrote:
>
>> Im getting this data on request.vars from Google forms onsubmit event.
>>
>> u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00'
>>
>> how do i convert it to
>> "Sistema de Gestão da Qualidade"
>>
>> i tried urllib.unquote(x).decode('utf-8')  in my controller
>> def getit():
>> ret={}
>> for x in request.vars:
>> temp=urllib.unquote(x).decode("utf-8")
>> ret[x]=request.vars[x];
>> db.responses.insert(allresponses=ret)
>> but my responses.allreponses document is saved as the same value
>> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 'testing'}
>> Allresponses field is a JSON Field
>>
>>
>>
>> Regards
>> António
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

 --
 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.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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 

Re: [web2py] Decode string

2016-08-19 Thread Richard Vézina
if you pass json through url to have to parse the string json dump...

Richard

On Fri, Aug 19, 2016 at 9:27 AM, António Ramos  wrote:

> I have started another thread called
> How does web2py save JSON fields?
>
> because i think its the json field that is messing my data on save
>
> thank you
>
> 2016-08-19 14:03 GMT+01:00 Richard Vézina :
>
>> You have to URL unquote not request.vars http://stacko
>> verflow.com/questions/16566069/url-decode-utf-8-in-python
>>
>> If you do request.vars.yourvarname what do you have?
>>
>> You can try request.vars.yourvarname.decode('utf-8')
>>
>>
>> Richard
>>
>>
>> On Thu, Aug 18, 2016 at 7:24 PM, António Ramos 
>> wrote:
>>
>>> Sorry to insist but cant find any clue.
>>> I tried a simple http post from fiddler or postman
>>>
>>> i sent a Post  to my controller with
>>> Content-Type: application/json; charset=utf-8
>>> and in the body
>>> {"Sistema de Gestão da Qualidade":1,"b":2}
>>>
>>> and i get in request.vars
>>> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 1, 'b': 2}
>>>
>>> How do i get "Sistema de Gestão da Qualidade" from the request.vars?
>>>
>>> Regards
>>> António
>>>
>>>
>>>
>>> 2016-08-18 19:49 GMT+01:00 Richard Vézina :
>>>
 I think it url encoded... Search google about it, it should be obvious
 then...

 Richard

 On Thu, Aug 18, 2016 at 2:12 PM, António Ramos 
 wrote:

> Im getting this data on request.vars from Google forms onsubmit event.
>
> u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00'
>
> how do i convert it to
> "Sistema de Gestão da Qualidade"
>
> i tried urllib.unquote(x).decode('utf-8')  in my controller
> def getit():
> ret={}
> for x in request.vars:
> temp=urllib.unquote(x).decode("utf-8")
> ret[x]=request.vars[x];
> db.responses.insert(allresponses=ret)
> but my responses.allreponses document is saved as the same value
> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 'testing'}
> Allresponses field is a JSON Field
>
>
>
> Regards
> António
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

 --
 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.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- 

Re: [web2py] Decode string

2016-08-19 Thread António Ramos
I have started another thread called
How does web2py save JSON fields?

because i think its the json field that is messing my data on save

thank you

2016-08-19 14:03 GMT+01:00 Richard Vézina :

> You have to URL unquote not request.vars http://
> stackoverflow.com/questions/16566069/url-decode-utf-8-in-python
>
> If you do request.vars.yourvarname what do you have?
>
> You can try request.vars.yourvarname.decode('utf-8')
>
>
> Richard
>
>
> On Thu, Aug 18, 2016 at 7:24 PM, António Ramos 
> wrote:
>
>> Sorry to insist but cant find any clue.
>> I tried a simple http post from fiddler or postman
>>
>> i sent a Post  to my controller with
>> Content-Type: application/json; charset=utf-8
>> and in the body
>> {"Sistema de Gestão da Qualidade":1,"b":2}
>>
>> and i get in request.vars
>> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 1, 'b': 2}
>>
>> How do i get "Sistema de Gestão da Qualidade" from the request.vars?
>>
>> Regards
>> António
>>
>>
>>
>> 2016-08-18 19:49 GMT+01:00 Richard Vézina :
>>
>>> I think it url encoded... Search google about it, it should be obvious
>>> then...
>>>
>>> Richard
>>>
>>> On Thu, Aug 18, 2016 at 2:12 PM, António Ramos 
>>> wrote:
>>>
 Im getting this data on request.vars from Google forms onsubmit event.

 u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00'

 how do i convert it to
 "Sistema de Gestão da Qualidade"

 i tried urllib.unquote(x).decode('utf-8')  in my controller
 def getit():
 ret={}
 for x in request.vars:
 temp=urllib.unquote(x).decode("utf-8")
 ret[x]=request.vars[x];
 db.responses.insert(allresponses=ret)
 but my responses.allreponses document is saved as the same value
 {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 'testing'}
 Allresponses field is a JSON Field



 Regards
 António

 --
 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.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Decode string

2016-08-19 Thread Richard Vézina
You have to URL unquote not request.vars
http://stackoverflow.com/questions/16566069/url-decode-utf-8-in-python

If you do request.vars.yourvarname what do you have?

You can try request.vars.yourvarname.decode('utf-8')


Richard


On Thu, Aug 18, 2016 at 7:24 PM, António Ramos  wrote:

> Sorry to insist but cant find any clue.
> I tried a simple http post from fiddler or postman
>
> i sent a Post  to my controller with
> Content-Type: application/json; charset=utf-8
> and in the body
> {"Sistema de Gestão da Qualidade":1,"b":2}
>
> and i get in request.vars
> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 1, 'b': 2}
>
> How do i get "Sistema de Gestão da Qualidade" from the request.vars?
>
> Regards
> António
>
>
>
> 2016-08-18 19:49 GMT+01:00 Richard Vézina :
>
>> I think it url encoded... Search google about it, it should be obvious
>> then...
>>
>> Richard
>>
>> On Thu, Aug 18, 2016 at 2:12 PM, António Ramos 
>> wrote:
>>
>>> Im getting this data on request.vars from Google forms onsubmit event.
>>>
>>> u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00'
>>>
>>> how do i convert it to
>>> "Sistema de Gestão da Qualidade"
>>>
>>> i tried urllib.unquote(x).decode('utf-8')  in my controller
>>> def getit():
>>> ret={}
>>> for x in request.vars:
>>> temp=urllib.unquote(x).decode("utf-8")
>>> ret[x]=request.vars[x];
>>> db.responses.insert(allresponses=ret)
>>> but my responses.allreponses document is saved as the same value
>>> {u'Sistema de Gest\xe3o\x00 \x00d\x00a\x00 \x00Q\x00u\x00': 'testing'}
>>> Allresponses field is a JSON Field
>>>
>>>
>>>
>>> Regards
>>> António
>>>
>>> --
>>> 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: upload field and IS_IMAGE

2016-08-19 Thread Kirill Shatalaev


пятница, 19 августа 2016 г., 3:48:12 UTC+4 пользователь 黄祥 написал:
>
> pls try :
> requires = IS_EMPTY_OR([IS_LENGTH(16384), IS_IMAGE() ] )
>
> best regards,
> stifan
>

Man, thanks!!! I completely forgot about this validator. Need to sleep 
more...

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] How does web2py save JSON fields?

2016-08-19 Thread António Ramos
Hi,im starting a new post because i found that JSON fields change data as
they are saved.
So repeating again the problem posted before


My model
db.define_table('responses',
Field('f1'),
Field('allresponses','json'))

My controller
def getit():
ret={}
for x in request.vars:
   db.responses.insert(f1=urllib.unquote(x))
   ret[urllib.unquote(x)]=request.vars[x];
db.responses.insert(allresponses=ret)

i get in my request.vars

{'Timestamp': '8/19/2016 9:54:44',
'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': 'sss'}

after executing the controller code,when i look at  table responses i see
in allresponses field
{'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 \x00d\x00e\x00
\x00Q\x00u\x00': 'sss'}

but field f1 is correct
"Sistema de Gestão de Qualidade"

So how can i deal with this?
This is just a test but i will get many keys in request vars and so a json
field would be better but need to solve this issue.

Regards
António

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: scheduler task_id assigned to multiple workers

2016-08-19 Thread Niphlod
yep. your worker setup clearly can't stably be connected to your backend.

On Thursday, August 18, 2016 at 7:41:38 PM UTC+2, Jason Solack wrote:
>
> so after some digging what i'm seeing is the sw.insert(...) is not 
> committing and the mybackedstatus is None, this happens 5 times and then 
> the worker appears and almost instantly disappers.  There are no errors.  i 
> tried manually doing a db.executesql but i'm having trouble getting 
> self.w_stats converted to something i can insert via sql.
>
> another things i'm noticing is my "distribution" in w_stats is None...
>
> Any ideas as to why this is happening?
>
> On Thursday, August 18, 2016 at 12:21:26 PM UTC-4, Jason Solack wrote:
>>
>> doing that now, what i'm seeing is some problems here:
>>
>> # record heartbeat
>>mybackedstatus = db(sw.worker_name == self
>> .worker_name).select().first()
>>if not mybackedstatus:
>>sw.insert(status=ACTIVE, worker_name=self.worker_name,
>>  first_heartbeat=now, last_heartbeat=now,
>>  group_names=self.group_names,
>>  worker_stats=self.w_stats)
>>self.w_stats.status = ACTIVE
>>self.w_stats.sleep = self.heartbeat
>>mybackedstatus = ACTIVE
>>
>> mybackedstatus is consistently coming back as "None" i'm guessing there 
>> is an error somewhere in that try block and the db commit is being rolled 
>> back
>>
>> i'm using MSSQL and nginx... currently upgrading web2py to see it 
>> continues
>>
>>
>>
>> On Thursday, August 18, 2016 at 10:44:28 AM UTC-4, Niphlod wrote:
>>>
>>> turn on workers debugging level and grep for errors.
>>>
>>> On Thursday, August 18, 2016 at 4:38:31 PM UTC+2, Jason Solack wrote:

 I think we have this scenario happening:


 https://groups.google.com/forum/#%21searchin/web2py/task_id%7csort:relevance/web2py/AYH5IzCIEMo/hY6aNplbGX8J

 our workers seems to be restarting quickly and we're trying to figure 
 out why

 On Thursday, August 18, 2016 at 3:55:55 AM UTC-4, Niphlod wrote:
>
> small recap...a single worker is tasked with assigning tasks (the 
> one with is_ticker=True) and then that task is picked up only by the 
> assigned worker (you can see it on the 
> scheduler_task.assigned_worker_name 
> column of the task). 
> There's no way the same task (i.e. a scheduler_task "row") is executed 
> while it is RUNNING (i.e. processed by some worker).
> The process running the task is stored also in 
> scheduler_run.worker_name.
>
>  you shouldn't EVER have scheduler_run records with the same 
> task_id and 12 different worker_name all in the RUNNING status.
>
> For a single task to be processed by ALL 12 workers at the same 
> time... is quite impossible, if everything is running smoothly. And 
> frankly 
> I can't fathom any scenario in which it is possible.
>
>
> On Wednesday, August 17, 2016 at 6:25:41 PM UTC+2, Jason Solack wrote:
>>
>> I only see the task_id in the scheduler_run table, it seems to be 
>> added as many times as it can while the run is going... a short run will 
>> add just 2 of the workers and stop adding them once the initial run is 
>> completed
>>
>> On Wednesday, August 17, 2016 at 11:15:52 AM UTC-4, Niphlod wrote:
>>>
>>> task assignment is quite "beefy" (sadly, or fortunately in your 
>>> case, it favours consistence vs speed) : I don't see any reason why a 
>>> single task gets picked up by ALL of the 12 workers at the same time if 
>>> the 
>>> backend isn't lying (i.e. slaves not replicating master data), if 
>>> your 
>>> mssql is "single", there shouldn't absolutely be those kind of 
>>> problems...
>>>
>>> Are you sure all are crunching the same exact task (i.e. same task 
>>> id and uuid) ?
>>>
>>> On Wednesday, August 17, 2016 at 2:47:11 PM UTC+2, Jason Solack 
>>> wrote:

 I'm using nginx and MSSQL for the db

 On Wednesday, August 17, 2016 at 3:11:11 AM UTC-4, Niphlod wrote:
>
> nothing in particular. what backend are you using ?
>
> On Tuesday, August 16, 2016 at 8:35:17 PM UTC+2, Jason Solack 
> wrote:
>>
>> task = scheduler.queue_task(tab_run, 
>> pvars=dict(tab_file_name=tab_file_name, 
>> the_form_file=the_form_file), 
>> timeout=60 * 60 * 24, sync_output=2, immediate=False, 
>> group_name=scheduler_group_name)
>>
>> anything look amiss here?
>>
>> On Tuesday, August 16, 2016 at 2:14:38 PM UTC-4, Dave S wrote:
>>>
>>>
>>>
>>> On Tuesday, August 16, 2016 at 9:38:09 AM UTC-7, Jason Solack 
>>> wrote:

 Hello all, i am having a situation where my