TurboGears: Python on Rails?
gcantallopsr writes "If you liked Ruby on Rails and its 15m intro video (.mov) you will probably like TurboGears and its 20 minute wiki tutorial. (.mov) It shows you the development of a simple wiki in just 20 minutes, and there is a text version of the tutorial. TurboGears uses Python, SQLObject, CherryPy, Kid, MochiKit and some extra pythonic glue to help you to (in their own words) 'Create a database-driven, ready-to-extend application in minutes. All with designer friendly templates, easy AJAX on the browser side and on the server side, not a single SQL query in sight with code that is as natural as writing a function.'"
But, man, it ain't rails. Look at this:
class Page(SQLObject):
_connection = hub
pagename=StringCol(alternateID=True, length=30)
data=StringCol()
To me, that looks too much like your typical Python code. Quite *readable* yes, but when you read it, you have no idea *why* all that stuff is there. StringCol? data=Stringcol()? And yes, a leading underscore thrown in for good measure (every Python program must have a few underscores thrown in.. I guess python programmers long for the dollar signs and punctuation of Perl).
Now look at the Rails (ActiveRecord) equivalent:
class Page < ActiveRecord::Base
end
Hmm, no boilerplate.
Now, let's have a laugh:
@turbogears.expose(html= "wiki20.templates.page" )
def index(self, pagename="FrontPage"):
page = Page.byPagename(pagename)
content = publish_parts(page.data, writer_name= "html" )[ "html_body" ]
content = content.encode( "utf8" )
return dict (data=content, pagename=page.pagename)
What is all that *STUFF* for? He even goes on to call that "very readable" !!! Here's the ruby version (as far as I can make it out, anyway):
def index
end
Do you see the difference? In a Rails app, most of the code is at the level of your problem domain, NOT the level of pushing bits around from the DB to the HTML templates. All the knock-offs are full of *noise*.
That's what makes Rails so lovely.
But I guess if you just refuse to use Ruby, you'll have to settle for what you can get.