Table Of Contents

The Project Structure

When you create a new TurboGears project, you will get a directory structure which at first glance seems to contains lots of files. It might seem difficult to understand their purpose but in practice, you need to know only about a small number of files. Those files can be categorized belonging to one of the four purposes listed below. Note that with TurboGears you’ll spend most of time on the files printed in bold.

Deployment

README.txt
Write about your project in here. By default this file gives instructions how to start the application.
setup.py
Packaging, distribution and installation related settings.
start-<yourprojectname>.py
To start your web application run this script with Python.
<yourpackagename>/release.py
Application related information, like version number, authors, copyright etc. is provided here.
<yourprojectname>.egg-info/
Auto-generated packaging meta-data from setup.py.

You can publish your project to the Python Cheeseshop in minutes by changing only a few lines in the above files. See the deployment documentation for further details.

Configuration

dev.cfg
The deployment-specific configuration settings in development mode go in here.
sample-prod.cfg
A template for deployment-specific configuration settings in production mode.
<your project name>/config/*.cfg
These files contains the deployment-independent configuration settings of your application

You do most of configurations for your project in those files. See the configuration reference for more information.

Development

<yourpackagename>/ controllers.py
Write your controllers (main program) here. If you use the quickstart template for big applications, this is a sub-package directory named controllers and the root controller will be in <yourpackagename>/controllers/root.py.
<yourpackagename>/ model.py
This file defines your application’s data model. If you chose to add identity support when creating your applications, the data model to support this has already been added to this file.
<yourpackagename>/ templates/
This is a package directory containing the templates (i.e. the view) () of your application.
<yourpackagename>/json.py
Contains rules for turning your data model objects into JSON notation (optional).
<yourpackagename>/command.py
This module contains functions that are intended to be run from the command line. By default it has the start-up code for your application and bootstrap command to create your database tables.
<yourpackagename>/static/
This directory contains all the static files, which are served by your application, like CSS files, images and JavaScript code.

Testing

<yourpackagename>/tests/*
Place your unit test code in this directory. Test your web application model, view, and controllers by writing a :doc:`/test`*.py file for each and run them trough nosetest.
test.cfg
This configuration file contains settings which are only active when running your application’s test suite. You may want to configure a different database and logging setup here.