On Thursday, March 31, 2011 3:52:47 PM UTC-4, VP wrote: 
>
>
> > I guess I can see leaving the default to re-map hyphens to underscores 
> but 
> > perhaps only on functions? 
>
> YES. 
>
> App names are file names, and people generally don't want to have 
> hyphens in their file names, which is the opposite of what they would 
> want for URLs.

 
Yes, that's exactly the point of the web2py router default behavior. People 
generally do not want hyphens in their app/folder, controller, or function 
names (at least in part because hyphens aren't allowed in Python 
identifiers), but they also do not want underscores in their URLs. Without 
any rewriting, you'd either have to have hyphens in your app, controller, 
and function names (which is undesirable/illegal), or you'd have to have 
underscores in your URLs (also undesirable). The current default router 
behavior allows you to use underscores in the internal names yet still have 
hyphens in the URLs. So, if you have app = 'my_app', controller = 
'my_controller.py', and action = 'my_action()', then you get a URL like 
/my-app/my-controller/my-function (likewise, an incoming URL like that gets 
properly mapped to the internal names with underscores). If you stick to the 
convention of only using underscores in the internal names (including the 
app name), then everything works great with the current default.
 

> As for app names, I think they should be left alone because the 
> typical convention for file naming is underscored, which is the 
> opposite of what is desired for URLs.  In other words, if people name 
> their files with underscores, it wouldn't be reasonable to assume they 
> want hyphens.

 
The router assumes if you name your app with underscores that you *do* want 
hyphens when the app name is displayed in a URL, and that does seem 
reasonable.
 
Best,
Anthony
 

Reply via email to