Chapter 2.4. Custom Greetings (Hello from the Controller)

Sure, that wasn’t much code, but it looks an awful lot like a static HTML page, and you probably want to see something more dynamic; so let’s take a look at how this simple application works and add a bit of dynamic content, which is generated in another Python file called the controller, to our page before we display it to the user.

In the hello project is a hello folder that contains the file controllers.py. This file is what gets called when you browse to your web application. When you open that file in a text editor, something like this displays:

import turbogears from turbogears import controllers, expose class Root(controllers.RootController): @expose(template="hello.templates.welcome") ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.