admin
01/23/06

TurboGears on OSX

TurboGears seems to be a very nice alternative to Ruby On Rails. It shares the appeal of the end-to-end Web Application framework, with a modern, productive language, but it is much more modest in terms of hype and world domination plans.
Although I do prefer Ruby as a programming language, Python (used by TurboGears) is a fine choice as well. I totally dig that it has a specific template language, I don't particularly like the native Ruby approach to the web pages on RoR. The persistency framework (SQLObjects) seems to be a nice choice, it has support for the usual suspects (MySQL, PostgreSQL, even the little embedded SQLite package). Although I was very impressed with RoR implementing all the required frameworks (DB, MVC, etc.) from scratch, TurboGears seems to be well integrated from the existing components.
As a beginner OSX user I had an moderately easy time getting it up and running, I attribute most of the work to my lack of Mac skills. There is a brief help page on TurboGears.org, but I needed to play around to get the expected results.

The fist step for me was to install MacPython. By default Apple ships Python 2.3.5 with Tiger, so this is needed to get Python 2.4 installed. The MacPython website is not very good in terms of documentation, but this is how I managed to get it running.
  1. I've installed the distribution from the .dmg file
  2. I've installed the TigerPython fix as well
  3. Now I needed to have the new MacPython as the default Python interpreter in the shell, so I needed to edit the ".bash_profile" file in my home directory. I've used TextWrangler's hidden file mode, as by default this file does not show up in the Finder or in the File Open dialogs
  4. I've added this line to my bash profile: PATH=/usr/local/bin:$PATH
  5. I've closed my shell and opened it again - apparently the "source .bash_profile" does the same trick
  6. Now, when you run "python -V" to get the python version in the shell, it should display 2.4.1 instead of 2.3.5. If you still see 2.3.5, check your path with "echo $PATH", as the "/usr/local/bin" location should precede the "/usr/bin" one, where old python shortcuts live
  7. While I was dicking around on the macpython website, I've also downloaded and installed the pysqlite package from http://pythonmac.org/packages/
  8. Next I've downloaded the ez_setup.py file from the TurboGears site
  9. Then I've run the ez_setup script as instructed on the TurboGears site: sudo python ez_setup.py -f http://www.turbogears.org/download/index.html --script-dir /usr/local/bin TurboGears

After this, I've created a project folder in my home directory, and used the "tg-admin quickstart" command to create the default web app structure, which completed successfully. Then I've started the web app with the generated Python script, and it showed up on the http://localhost:8080 address, to my great pleasure.

Now I only need to complete the code for the application...
February 2012
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Search

Random photo

XML Feeds

powered by b2evolution