Survey application with TurboGears and CatWalk

Part Tree


Rendering your surveys

We want to show our published surveys to our users and let them choose, fill and submit a survey.

We open our controller file and edit our index method. Index should return a list of published surveys:

Remember to import your model in your controller file

We procede to create a new kid template file called 'surveys.kid' it will look like this:

Go to your browser and se it working =)

Rendering your survey

To render our survey we implement a method called 'show' that expect a survey id as a parameter and returns a dictionary with the survey properties, questions and options:

Now let's do some Kid Kong Fu. We create a new template called survey.kid which renders the survey properties and loops trough it's questions. The work of rendering each question type is delegated to templates functions based on the question type.

Our rendered survey now looks like this:

Copyright © 2004-2005 Ronald Jaramillo. All rights reserved. Contact & feedback