Modelling a Turbogears Application
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:
class CategoriesController:
@turbogears.expose(html="klangorg.templates.blog.category")
def default(self,category):
return self.category(category)
@turbogears.expose(html="klangorg.templates.blog.category")
def category(self,categoryID):
category = Category.get(categoryID)
return dict(category=category)
because the SQLObject mapper gives me categories.posts() for free.
The structure I visualized looked something like the picture.
Comments
http://groups.google.com/group/nheb-h...
http://groups.google.com/group/arabwe...
http://groups.google.com/group/acxsouth
http://groups.google.com/group/tx-lnh...
http://groups.google.com/group/tvxvid
http://groups.google.com/group/wsmgr/...
http://groups.google.com/group/tvxvid...
http://groups.google.com/group/tvxvid...
http://groups.google.co.uk/group/netv...
http://message.diigo.com/message/tvx-...
http://esgit.com/8/map413.html http://homebuyall.com/11/map2.html http://esgit.com/8/map152.html http://homebuyall.com/15/map354.html http://homebuyall.com/13/map428.html http://homebuyall.com/14/map216.html http://homebuyall.com/11/map228.html http://esgit.com/5/map115.html http://esgit.com/7/map482.html http://homebuyall.com/14/map278.html http://esgit.com/6/map491.html http://homebuyall.com/14/map470.html http://homebuyall.com/15/map138.html http://esgit.com/7/map431.html http://homebuyall.com/14/map395.html http://esgit.com/6/map286.html http://esgit.com/5/map490.html http://homebuyall.com/15/map452.html http://esgit.com/9/map348.html http://esgit.com/7/map13.html http://esgit.com/7/map151.html http://homebuyall.com/11/map226.html http://esgit.com/5/map30.html http://esgit.com/8/map107.html http://homebuyall.com/11/map130.html http://homebuyall.com/14/map285.html http://esgit.com/5/map347.html http://esgit.com/7/map334.html http://esgit.com/8/map358.html http://esgit.com/8/map367.html http://homebuyall.com/11/map457.html http://homebuyall.com/13/map211.html http://homebuyall.com/14/map264.html http://homebuyall.com/15/map28.html http://homebuyall.com/13/map54.html http://homebuyall.com/12/map198.html http://homebuyall.com/13/map241.html http://esgit.com/7/map211.html http://homebuyall.com/12/map302.html http://esgit.com/5/map156.html http://esgit.com/5/map465.html http://homebuyall.com/14/map237.html http://homebuyall.com/15/map116.html http://esgit.com/5/map68.html http://esgit.com/6/map151.html http://homebuyall.com/13/map494.html http://esgit.com/6/map352.html http://esgit.com/7/map121.html http://homebuyall.com/13/map442.html http://homebuyall.com/12/map164.html
http://technocrete.ae/imgs/index.php
http://apnet.org/imgs/index.php
http://technocrete.ae/imgs/index.php
http://mensvichotel.com/imgs/index.php
http://technocrete.ae/imgs/index.php
http://apnet.org/imgs/index.php
http://apnet.org/imgs/index.php
http://seriilan.ac/imgs/index.php
http://mensvichotel.com/imgs/index.php
http://apnet.org/imgs/index.php
http://seriilan.ac/imgs/index.php
http://mensvichotel.com/imgs/index.php
http://apnet.org/imgs/index.php
frasa.t35.com
Post a comment