Ultimately, the final product in a webapp appears in the form of executable code. Because of this, code makes a good frame of reference when talking about a programming tool. The quickest way to have some code with TurboGears is using the tg-admin tool.
tg-admin is a command line companion for the TurboGears library. It works through subcommands that let you: create a new project, manipulate your database, and interact in an object-oriented way with your database.
The reference for tg-admin provides the details on the commands. If you just run tg-admin without specifying any commands, you'll see the list of what's available.
For now, we'll use the "quickstart" command, so that we have some code to use as a frame of reference:
tg-admin quickstart
If you add the "--help" option to the commands, you can see what options each command takes. For quickstart, you can specify everything on the command line or be prompted for the information needed to get going. Odds are that you won't run quickstart that often. You never know, though. It's really easy to get going!
We'll just use "gs" (for "getting started") as our project and package names.
Enter project name: gs
Enter package name [gs]:
Selected and implied templates:
TurboGears#tgbase tg base template
TurboGears#turbogears web framework
Variables:
package: gs
project: gs
Creating template tgbase
Creating ./gs/
Recursing into +einame+.egg-info
Creating ./gs/gs.egg-info/
Copying PKG-INFO to ./gs/gs.egg-info/PKG-INFO
Copying paster_plugins.txt to ./gs/gs.egg-info/paster_plugins.txt
Copying sqlobject.txt_tmpl to ./gs/gs.egg-info/sqlobject.txt
Recursing into +package+
Creating ./gs/gs/
Copying __init__.py to ./gs/gs/__init__.py
Copying release.py_tmpl to ./gs/gs/release.py
Recursing into static
Creating ./gs/gs/static/
Recursing into css
Creating ./gs/gs/static/css/
Copying empty to ./gs/gs/static/css/empty
Recursing into images
Creating ./gs/gs/static/images/
Copying favicon.ico to ./gs/gs/static/images/favicon.ico
Copying tg_under_the_hood.png to ./gs/gs/static/images/tg_under_the_hood.png
Recursing into javascript
Creating ./gs/gs/static/javascript/
Copying empty to ./gs/gs/static/javascript/empty
Recursing into templates
Creating ./gs/gs/templates/
Copying __init__.py to ./gs/gs/templates/__init__.py
Creating template turbogears
Recursing into +package+
Recursing into config
Creating ./gs/gs/config/
Copying __init__.py to ./gs/gs/config/__init__.py
Copying app.cfg_tmpl to ./gs/gs/config/app.cfg
Copying controllers.py_tmpl to ./gs/gs/controllers.py
Copying model.py_tmpl to ./gs/gs/model.py
Recursing into sqlobject-history
Creating ./gs/gs/sqlobject-history/
Copying empty to ./gs/gs/sqlobject-history/empty
Recursing into templates
Copying login.kid to ./gs/gs/templates/login.kid
Copying master.kid to ./gs/gs/templates/master.kid
Copying welcome.kid to ./gs/gs/templates/welcome.kid
Recursing into tests
Creating ./gs/gs/tests/
Copying __init__.py to ./gs/gs/tests/__init__.py
Copying test_controllers.py_tmpl to ./gs/gs/tests/test_controllers.py
Copying test_model.py_tmpl to ./gs/gs/tests/test_model.py
Copying README.txt_tmpl to ./gs/README.txt
Copying dev.cfg_tmpl to ./gs/dev.cfg
Copying prod.cfg_tmpl to ./gs/prod.cfg
Copying setup.py_tmpl to ./gs/setup.py
Copying start-+package+.py_tmpl to ./gs/start-gs.py
Running /usr/local/bin/python setup.py egg_info
Adding TurboGears to paster_plugins.txt
running egg_info
writing requirements to gs.egg-info/requires.txt
writing gs.egg-info/PKG-INFO
writing top-level names to gs.egg-info/top_level.txt
reading manifest file 'gs.egg-info/SOURCES.txt'
writing manifest file 'gs.egg-info/SOURCES.txt'
This command gave us a clean-slate web application, ready to start filling in with real code.