Site Layout and Structure ¶
Warning:
This page is a work in progress. Add comments or corrections at bottom.
There is an example App Engine site within the Tipfy package contained in the in the project/app/ directory (src).
Note:
There is no rigid structure defined by Tipfy, but presented is a suggested structure to get started. You are encouraged to hack an application structure the way you want it.
For this example, we'll copy this directory to a new demo App named fooapp.appspot.com.
cp -R app/ fooapp.appspot.com
Default Site Structure¶
The "site" structure is basic and has the following featured elements.
- fooapp.appspot.com/
- app.yaml - the app engine site configuration file (src)
- main.py - Entry point of application (src)
- config.py - covered in the next section configuration (src)
- urls.py - TODO - covered in guide/routing (src)
- apps/ - this is where all your apps go (ie apps within your application, think modules), such as wiki, pastebin, etc.
- lib/ - TODO - where should the tipfy lib go?
- locale/ - where translations are stored.
- static/ - location of staticly served appengine files.
- favicon.ico and robots.txt as placeholders
- templates/ - where the templates go. Jinja2 is the templating engine used by default.
- hello_world.html - a placeholder jinja2 template for hello_world app/module.
Running the App¶
Before running the fooapp, here's a brief explanation of the "execution path" that occurs..
- Browser requests http://localhost:8080/pretty
- The App Engine fires up the Application with app.yaml configuration.
- main.py is loaded.
- config.py and config dictionary is loaded
- WSGI app created and run
- tipfy
- loads the
/urls.pyin root which in turn loadsapps/*/urls.pyincluded" in/config.py - Finds the handler for http://localhost:8080**/pretty
- Handler is
apps.hello_world.handlers.PrettyHelloWorldHandler
- Handler is
- loads the
import apps.hello_world.handlers.PrettyHelloWorldHandlerclassclass PrettyHelloWorldHandler(RequestHandler)is createddef get(self):is called as its a GET requestreturn render_response('hello_world.html', message='Hello, World!')templates/hello_world.htmlis loaded and parsed.- Response object returned
- WSGI app send to browser.
- Or some error message if caught
- Version: latest
- Edited by Vinay Sajip on 10/23/10 5:44 AM
- Save on Delicious | Submit to Reddit
- History
- Edit
