On May 1, 2011, at 7:23 AM, Syed Mushtaq wrote: > Thanks Massimo for the reply , > > I tried with the comma at the end but no luck :( > > I traced it back to the code where it was giving a 400 and found that its not > able to match the regular expression in > rewrite.py function regex_url_in line 542 , The regular expression for this > is
Notice that this regex includes \s for the fields it's checking, which will pass spaces (and tabs!) (they get converted to underscores later). OTOH, regex_args does not permit whitespace, and also results in a 400 response, which may be what you're running into. The parametric router gives you a little more control over this stuff; see router.example.py. > > regex_url = re.compile(r''' > (^( # (/a/c/f.e/s) > /(?P<a> [\w\s+]+ ) # /a=app > ( # (/c.f.e/s) > /(?P<c> [\w\s+]+ ) # /a/c=controller > ( # (/f.e/s) > /(?P<f> [\w\s+]+ ) # /a/c/f=function > ( # (.e) > \.(?P<e> [\w\s+]+ ) # /a/c/f.e=extension > )? > ( # (/s) > /(?P<r> # /a/c/f.e/r=raw_args > .* > ) > )? > )? > )? > )? > /?$) > ''', re.X) > > now it has \w which means it checks only for [A-Za-z0-9_] so a - or space > will not be matched leading to 400 . I am using a workaround of replacing > space/hyphens with underscore for now > > Thanks > -Syed > > On Sun, May 1, 2011 at 11:44 AM, Massimo Di Pierro > <massimo.dipie...@gmail.com> wrote: > yes > > routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name'), ) > routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name'), ) > > the extra comma at the end. ;-) > > > > On May 1, 12:58 am, Syed Mushtaq <syed1.mush...@gmail.com> wrote: > > Hi , > > > > I was using rewrite for making the URL reader friendly . When I use a space > > or hypen in the URL instead of passing it to the controller , it gives an > > invalid request . > > > > I have configured the routes as follows > > > > routes_in = (( r'/$id/$name' , r'/app/default/view/$id/$name') ) > > > > routes_out = ( ( r'/app/default/view/$id/$name' , r'/$id/$name') ) > > > > Is there something I am missing ? > > > > Thanks > > -Syed >