On Mar 29, 2012, at 11:33 AM, Simon Bushell wrote: > This is a neat solution Anthony (actually, it was my original idea for > solving this). however I seem to be getting the same error: invalid function > (default/tcgata). > > Forgive me, is this code in the root-level routes.py? or a routes.py in > applications/shortener? > > Should anything else be in routes.py?
If I'm remembering this correctly, you want something like this (root level is fine): routers = dict( BASE = dict( default_application = 'shortener', ), shortener = dict( default_controller = 'default', default_function = 'index', functions = ['index', 'user', 'download', 'call'], ), ) ...where the functions list is a complete list of the visible functions in the default controller (that is, any function that can appear in a URL). The router needs that list so it can distinguish function names from args, and can then omit 'index'. Since in your example tcgata is not in the functions list, it can be safely treated as args[0]. > > S > > > > On Thursday, March 29, 2012 6:40:09 PM UTC+1, Anthony wrote: > routes_in = ( > (r'^/?$', r'/app_name/default/index'), > (r'^/(?P<url>[^/]*)/?$', r'/app_name/default/index/\g<url>'), > > ) > > > in your root-level routes.py The drawback is that you will lose access to all > other apps (including admin) but that can be a good thing for public > deployments. > > You can catch the other apps by adding route patterns that match them before > your catch-all pattern (the patterns are processed in order, and the first > match is used). Anyway, using the parametric router and specifying the > url-shortening app as the default app might be simpler: > > routers = dict( > BASE = dict( > default_application = 'shortener', > default_controller = 'default', > default_function = 'index', > ), > ) > > Then http://myapp.com/tcgata will get routed to > http://myapp.com/shortener/default/index/tcgata, and "tcgata" will be > available to the index() function in request.args(0). >