My suggestions on Web2py's route design
Learning web2py, it's an excellent yet young python web framework, I just wrote a few suggestions in the dev group: (route to controllers- Some idea may take from ASP.NET MVC's design)
I am learning web2py and very new to Python, so I could be wrong or I am not yet understand Massimo Di Pierro's principles, just some opinions for discuss.
Looks like the URL rules /[applicaiton]/[controller]/[function] is hard coded, I saw the code in main.py (lines near 140) :
request.application=items[0]
request.controller=items[1]
request.function=items[2]And also I found /static/... is hard coded as well.
Yes, with rewrite.py(route.py), we can rewrite any URL in this format and rewrite any this kind of URL to whatever we want. However there maybe some design which could be more flexible and yet keep CoC in good shape.
Look at the latest Microsoft ASP.NET MVC (now in preview 3, you can read this blog http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx to get some general idea), it also have a route mapping mechanism, you can write your rule to define which part means "controller" which part means "action", if you read the blog post I give, in the end part it introduced the route.
Something interesting is, that new added route part is NOT a part of ASP.NET MVC framework, it's actually useful for some other senarios, e.g. new release ASP.NET dynamic data applications(ASP.NET's answer to scaffold)
My points is, a more flexible routing mechanism could make the architect looks better and more flexible and you won't need to give up the compatibility and CoC principle.
ASP.NET MVC's design learned a lot from Ruby On Rails, actually RoR's route design is also quite flexible (refere to http://manuals.rubyonrails.com/read/chapter/65)
Related posts:
- To "refresh" a SqlDataSource.
- asp:ControlParameter vs asp:FormParameter
- output a line in a batch *without* crlf
- Write code with no getters???
- Dump SQL Server Express' DB Schema
- My suggestions on Web2py's route design
- Good comparing of GAE Data Store .vs. Amazon Simple DB .vs. MS SSDS
- Very good articles on MVC, MVP and more.
- Presenter First approach in MVP
- ASP.NET MVC Preview 3 just released
Search related in web: