On Feb 20, 2011, at 8:39 AM, Ross Peoples wrote:
> That would be pretty cool! So, assuming this was in the current release now, 
> I would set the 'functions' variable inside routes.py or to the controller? 
> And then if you visit a function that doesn't exist, it falls back to index, 
> with the original URL as the first argument?

Right.

You'd write this in routes.py:

routers = dict(
    BASE = dict( default_application='myapp', ),
    myapp = dict( functions=['index', 'user', 'help', 'whatever'),
)

You want functions= in an app-specific section, since it's, um, app-specific. 
But it's only useful for the default application.

The application might want to have a list of "forbidden" slug strings. It's not 
the end of the world if one gets used, because URL would do the right thing. 
Suppose you used URL to create a link to a post named 'help', with the above 
routers config. URL() would give you /index/help, because it would recognize 
that /help would refer to the function, not the post.

An application can call rewrite.get_effective_router(appname) to get the dict 
that's being used to rewrite URLs for that application, and use that to build a 
stop list for slug naming by looking at the applications, controllers & 
functions lists. With the caveat that the applications list might change: 
whether you can use a bare slug 'welcome' depends on whether there's an 
application installed by that name. (Again, URL will do the right thing, but 
/welcome will refer to the app, not the slug.)

Reply via email to