On Dec 27, 2011, at 2:49 AM, lyn2py wrote: > I already have in routes.py: > routers = dict( > BASE = dict( > default_controller='default', > default_function='index' > ) > ) > > How should my code be organized so that I can achieve: > website.com/items --> shows all the items > website.com/items/127 --> displays details of item #127 > > Right now, it's being done this way: > website.com/items --> shows all the items > website.com/items/display/127 --> displays details of item #127 > > Must the changes be made to routes.py or can the code base be slightly > modified to achieve it?
An easy way is to put the item number in a query string: website.com/items?127 Another way would be to use the function default/items instead of items/index. If you really, really want items to be a controller and have the URL syntax you're looking for, use something like this: routers = dict( yourapp = dict( functions = { 'items' : ['index', ... ] } ) ) The idea is that you need to inform the router of the function names in the items controller. Suggestion: website.com/item/127 looks a little more natural than items/127, at least to me. Easiest to do by putting your code in default/item and default/items.