[web2py] How does web2py save JSON fields?
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: upload field and IS_IMAGE
пятница, 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.
Re: [web2py] Decode string
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.
Re: [web2py] Decode string
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
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) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Googl
Re: [web2py] Decode string
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 unsubscribe from this group and stop receiving emails from it, send an >> email to web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.g
[web2py] Re: How does web2py save JSON fields?
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.
[web2py] LDAP authentication and user creation
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.
Re: [web2py] Re: How does web2py save JSON fields?
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.
Re: [web2py] Re: How does web2py save JSON fields?
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?
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.
[web2py] Re: New to web2py. Template use cases
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?
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
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.
[web2py] Re: New to web2py. Template use cases
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.
Re: [web2py] Re: How does web2py save JSON fields?
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 https://groups.google.com/d/optout.
Re: [web2py] Re: How does web2py save JSON fields?
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) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message be
Re: [web2py] Re: How does web2py save JSON fields?
[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 more options, visit https://groups.google.com/d/optout. >>> >> >> -- > Resources:
Re: [web2py] Re: How does web2py save JSON fields?
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 - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://co
Re: [web2py] Decode string
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 (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because