On Mar 24, 2011, at 8:04 AM, VP wrote: > > Noticing the version of web2py keeps interestingly increasing to 2.0, > I think this is something Massimo might want to spend sometime > thinking about. > > As I understand it, because of "exec", controllers are called *after* > the request arrives. This allows web2py to do a few interesting > things that other frameworks can't. > > On the other hands, this is an example that shows an advantage of > being able to manipulate controllers (concisely) *before* the request > arrives. > > I found myself constantly type checking controller arguments (e.g. > making sure an "id" is a number). This is another example where being > able to specify a certain syntax to the URL is very helpful. >
Notice that the routing mechanism you're talking about doesn't depend on the routing information being distributed as controller decoration; they can be presented in a table instead. In fact, putting them in a table has advantages over the decorator approach, in that a) you can see the whole routing policy in one place, and b) you can explicitly specify the order of evaluation. Checking controller arguments is important, since they are, after all, user input and not trustworthy. And there's something to be said for checking them at the controller/function, since you're in a position to give more informative error messages if something is wrong. If you're using web2py forms, then the validators serve this purpose. If you're not, you can use the validators on their own.

