| | 1 | """ |
|---|
| | 2 | Place to hold TurboGears built-in templates |
|---|
| | 3 | |
|---|
| | 4 | With 'paster quickstart' or 'paster create' command you can create a new |
|---|
| | 5 | TurboGears project which you can use as a basis for your own project. |
|---|
| | 6 | Let's take the command 'paster quickstart helloworld' for example. |
|---|
| | 7 | The generated directory structure is as follows:: |
|---|
| | 8 | |
|---|
| | 9 | - helloworld/ |
|---|
| | 10 | - helloworld/ |
|---|
| | 11 | - development.ini |
|---|
| | 12 | - setup.cfg |
|---|
| | 13 | - setup.py |
|---|
| | 14 | - test.ini |
|---|
| | 15 | |
|---|
| | 16 | |
|---|
| | 17 | The setup.py file is used to create a re-distributable Python |
|---|
| | 18 | package of your project called an egg. Eggs can be thought of as |
|---|
| | 19 | similar to .jar files in Java. |
|---|
| | 20 | The setup.cfg file contains extra information about your project. |
|---|
| | 21 | |
|---|
| | 22 | The sub 'helloworld' directory within the root 'helloworld' directory |
|---|
| | 23 | is where all your application specific code and files are placed. |
|---|
| | 24 | The sub directory looks like this:: |
|---|
| | 25 | |
|---|
| | 26 | - helloworld/ |
|---|
| | 27 | - config/ |
|---|
| | 28 | - controllers/ |
|---|
| | 29 | - lib/ |
|---|
| | 30 | - model/ |
|---|
| | 31 | - public/ |
|---|
| | 32 | - templates/ |
|---|
| | 33 | - tests/ |
|---|
| | 34 | - __init__.py |
|---|
| | 35 | - websetup.py |
|---|
| | 36 | |
|---|
| | 37 | The config directory contains the configuration options for your web application. |
|---|
| | 38 | |
|---|
| | 39 | The controllers directory is where your application controllers are written. |
|---|
| | 40 | Controllers are the core of your application where the decision is made on what |
|---|
| | 41 | data to load, and how to view it. |
|---|
| | 42 | |
|---|
| | 43 | The lib directory is where you can put code that is used between different |
|---|
| | 44 | controllers, third party code, or any other code that doesn't fit in well elsewhere. |
|---|
| | 45 | |
|---|
| | 46 | The models directory is for your model objects, if you're using an ORM this is |
|---|
| | 47 | where the classes for them should go. |
|---|
| | 48 | Objects defined in models/__init__.py will be loaded and present as model. |
|---|
| | 49 | YourObject inside your controllers. The database configuration string can be set |
|---|
| | 50 | in your development.ini file. |
|---|
| | 51 | |
|---|
| | 52 | The public directory is where you put all your HTML, images, Javascript, CSS and |
|---|
| | 53 | other static files. It is similar to the htdocs directory in Apache. |
|---|
| | 54 | |
|---|
| | 55 | The templates directory is where templates are stored. Templates contain a mixture of |
|---|
| | 56 | plain text and Python code and are used for creating HTML and other documents in a way |
|---|
| | 57 | that is easy for designers to tweak without them needing to see all the code that |
|---|
| | 58 | goes on behind the scenes. |
|---|
| | 59 | |
|---|
| | 60 | TurboGears 2 uses Genshi templates by default but also supports Mako, and jinja |
|---|
| | 61 | out of the box. Cheetah, Kid and any other template system you want can be |
|---|
| | 62 | easily used by writing a simple render function for them. |
|---|
| | 63 | |
|---|
| | 64 | The tests directory is where you can put controller and other tests. The controller |
|---|
| | 65 | testing functionality uses Nose and paste.fixture. |
|---|
| | 66 | |
|---|
| | 67 | The __init__.py file is present so that the helloworld directory can be used as a Python |
|---|
| | 68 | module within the egg. |
|---|
| | 69 | |
|---|
| | 70 | The websetup.py should contain any code that should be executed when an end user of your |
|---|
| | 71 | application runs the paster setup-app command described in Application Setup. |
|---|
| | 72 | If you're looking for where to put that should be run before your application is, |
|---|
| | 73 | this is the place. |
|---|
| | 74 | |
|---|
| | 75 | """ |
|---|