As I was envisioning the structure of the code for this blog, I was reminded of the style of module or functional modelling, as opposed to a strictly object-oriented approach
Posted by 11/09/2005
Modelling a Turbogears application
Putting together this blog in Turbogears I was thinking of how I visualized the structure. What I envisioned reminded me of old style module based documentation i.e. function based. The method of matching a url to a method is very much a functional view of the interactions and workings of a web site. There is a simplicity and directness of this approach that is nice to work with after setting up the struts-config.xml, ActionForwards, FormBeans and the like in the Struts framework. All I have to do to activate the controllers for the site is something like this:
cherrypy.root = Root()
cherrypy.root.blog = BlogController()
cherrypy.root.blog.admin = AdminController()
cherrypy.root.blog.archives = ArchivesController()
cherrypy.root.blog.categories = CategoriesController()
cherrypy.root.blog.comments = CommentsController()
And then each of the controllers just has a method to match a url and the parameters are the parameters that are sent to the function. So there is no method with a necessary (HttpRequest request) parameter - and no need for request.getParameter("parameter");. So, for instance, the pages that group posts by category are as simple as this:
category = Category.get(categoryID)
because the SQLObject mapper gives me categories.posts() for free.
The structure I visualized looked something like the picture.