I think we need an explicit issue to understand the problem. Open an issue so we can track it even if I do not think there is an issue.
On Monday, 4 May 2015 10:56:35 UTC-5, Louis Amon wrote: > > I've recently had a pretty annoying issue when using web2py with AngularJS > : > > By default, AngularJS sends JSON-encoded requests when you use the $http > service, so a POST request would look like this : > "{"firstName":"John"}" > > > For some reason I don't really understand, web2py natively understands > this JSON request a populates request.vars accordingly. > > Why does web2py understand JSON requests ? Aren't POST requests (forms) > supposed to be url-encoded ? > > > The issue I ended up facing because of this is when AngularJS sends a > request that contains accentuated characters, e.g. : > "{"firstName":"Cédric"}" > > When the regular HTML form processing would require something like: > "firstName=C%C3%A9dric" > > > > With the JSON request, web2py ends up populating request.vars like this : > Storage(firstName=u'Cédric') > > And so I get tons of *UnicodeEncodeError* when using web2py widgets or > the URL helper... > > For instance I have a URL(..., vars=request.vars) in a model and this > raises an Exception (HTTP 500) every time the server receives a > JSON-encoded request with accentuated characters. > > > *Shouldn't web2py be able to either convert JSON-encoded unicode strings > ot reject them altogether without raising an exception ?* > > > > ...for the record : my solution so far was to hack the $http service in > AngularJS into sending url-encoded strings instead of JSON. > > I started this post solely because I think there is something wrong going > on here with web2py and because many people post about UnicodeEncodeError > in web2py > -- 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.