On 5 Sep 2013, at 12:11 AM, Wonton <rferb...@gmail.com> wrote:
> Hello Marcio,
> 
> First of all, thank you so much for your answer, I haven thought on that 
> possibility and it's very interesting.
> 
> However, I have a huge number of services and I often test them manually, so 
> I would like to maintain the URLs as readable as possible. I would like to 
> try first with the routes.py solution, disabling the args validation for my 
> app. But I will keep in mind your solution.

Did you restart web2py after changing routes.py? routes_apps_raw ought to do 
what you want.

When your app is in the routes_apps_raw list, your args string (eg 
'json/public_function/...') is in request.raw_args (as usual) and request.args 
is None. It's then the responsibility of your app (and you can do this in your 
model if you like) to validate and parse request.raw_args, and (if you want to) 
put the results in request.args as a List() object.

Putting routes.py in the wrong place (it should be in the web2py root) or 
changing it without restarting is the most common reason for trouble with 
routes.py.

(As an alternative you can use the parametric router and specify your own 
validation regex for args: args_match.)

> 
> Kind regards!
> 
> On Thursday, September 5, 2013 3:50:17 AM UTC+2, Marcio Andrey Oliveira wrote:
> Can't you send encoded parameters (say in Bas64 or hexadecimal) and decode 
> them inside the methods?
> 
> Regards.
> 
> On Wednesday, September 4, 2013 8:24:26 PM UTC-3, Wonton wrote:
> Hello everyone!
> 
> I've developed a web2py backend which is given me problems with special chars 
> in URLs. I'm a newbie with web2py so maybe I'm missing something very easy, 
> sorry if that is the case ;-).
> 
> These are the details of my app.
> 
> - I have no routes.py file.
> 
> - In controllers/default.py I have this:
> 
> 
> ...
> public_services=Service()
> private_services=Service()
> ...
> def public_call(): 
>     return public_services()
> 
> @auth.requires_login()
> def private_call(): 
>     return private_services()
> ...
> @public_services.json
> def public_function_1(var1, var2, var3):
> ...
> @private_services.json
> def private_function_1(var1, var2):
> ...
> 
> 
> - I call these methods this way:
> 
> http://mydomain/myapp/default/public_call/json/public_function_1/var1/var2/var3
> http://mydomain/myapp/default/private_call/json/private_function_1/var1/var2
> 
> - Everything is working except if my URL contains special chars, (var1, var2 
> or var3 can contain 'ñ' or accents, coded with %...) then I get an "invalid 
> request" error.
> 
> - After reading all posts related to this issue I'm a bit lost, sorry. I've 
> tried to create a routes.py and the only line inside it is this:
> routes_apps_raw=['myapp']
> 
> But obviously this is not enough because I have the same problem yet.
> 
> Besides this, I don't understand the "request.raw_args" thing, am I supposed 
> to do anything with that? I can't see any request.raw_args in my code.
> 
> Thank you very much and kind regards!
> 
> 
> -- 
>  



-- 

--- 
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/groups/opt_out.

Reply via email to