Log in

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.
      • hello_world/ - and example app/module (more below)
        • urls.py - the routes for this app/module (src).
        • handlers.py - the Request handlers for this app/module (src)
    • 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.py in root which in turn loads apps/*/urls.py included" in /config.py
    • Finds the handler for http://localhost:8080**/pretty
      • Handler is apps.hello_world.handlers.PrettyHelloWorldHandler
  • import apps.hello_world.handlers.PrettyHelloWorldHandler class
  • class PrettyHelloWorldHandler(RequestHandler) is created
    • def get(self): is called as its a GET request
      • return render_response('hello_world.html', message='Hello, World!')
        • templates/hello_world.html is loaded and parsed.
          • Response object returned
  • WSGI app send to browser.
    • Or some error message if caught

Powered by Moe. Yeah, the name is Moe. Powered by Google App Engine