On 27 Aug 2012, at 7:30 AM, jc <[email protected]> wrote:
> I want to shorten url's and use hyphens in my paths. I also want to get a 404 
> if the user tries an invalid url. I have played with routes.py but the effect 
> I get is shorter url's (good), hyphens in url's translated to underscores in 
> function and view (good) , but all invalid url's route to the default a/c/f 
> (bad). So the user doesn't see they have used an invalid url, they just get 
> the home page.
> 
> With this as my routes.py 
> 
> routers = dict(
>   BASE = dict(
>     default_application = 'app',
>     map_hyphen = 'True',
>   ),
>   app = dict(
>     default_controller = 'cc',
>     default_function = 'f1',
>     functions = ['f1', 'f2', ...],
>   ),
> )
> 
> then
> http://domain/ --> home page
> http://domain/app --> home page
> http://domain/app/cc --> home page etc.
> http://domain/f2 --> f2 correctly
> 
> But http://domain/bad-app-name --> home page too, which I don't want.
> 
> Is this correct behaviour? How can I achieve my goal?
> 

It's correct behavior. In your example, the router interprets your example as 
http://domain/app/cc/f1/bad-app-name because it figures that 'bad-app-name' 
must be an arg (request.args[0]). You can avoid that by leaving out the 
functions= line. The downside of *that* will be that 'f1' will not be omitted 
if there really is an arg.

-- 



Reply via email to