I’ve been reading TurboGears website, wiki, & FAQ for almost 2 weeks, now it’s about time to build something with it.
Below are steps I’ve done to have some sort of “Hello World” stuff.
Some Basic Pre-Assumptions
- You have already installed Python
- You will want to install easy_install. Read this for install instruction. Easy Install is like apt-get for Python modules.
Installation
- Download tgsetup.py from TurboGears website. Then run the script by calling python tgsetup.py
- The process above will install a whole bunch of TurboGears component such as:
- Kid(think CakePHP’s thml or Rails’ rhtml)
- CherryPy(think of WebServer)
- SQLObject (think Rails ActiveRecord) is preferred by TurboGears, so we need to install it. In your command-line console, type: easy_install sqlobject.
- When above are all finished, it’s time to create new project.
Creating New Project
- TurboGears gives you tg-admin tool (just like Rails’ generate or CakePHP bake script), so let’s use it.
- tg-admin is an interactive command-line tool which help you building some basic structure for your application.
- When this process is finished, see if your project is runnable.
Run the Web Server, See if Your Project is Runnable
- Inside your project directory, from command-line, type: python start-{your_project_name}.py
- By default, the web server (which is CherryPy) is using port: 8080. If that’s being used, change the configuration, which I will tell you how below.
Changing the Configuration
- The default configuration of TurboGears is pretty light weight, not quite real life setting. If you don’t like it, modify dev.cfg file.
- Inside dev.cfg file, you can:
- use MySQL instead of SQLLite
- Change the port of your Web Server
- and more…
- Try restarting the server, see if your new configuration works.
Well, congratulation, you just created the structure for your next WEB 2.0 project!
In the next series, I will describe my adventure, using TurboGears, to build: Calculator! The next big thing in Web 2.0 world.