.. tg2_app_example: TurboGears 2 ============ This tutorial assumes basic familiarity with TurboGears 2. Beginners should read the TurboGears 2 `Wiki tutorial`_. The tutorial was developed using TurboGears 2.0b4. .. _Wiki tutorial: http://turbogears.org/2.0/docs/main/Wiki20/wiki20.html First, quickstart an app using the standard approach. It doesn't really matter what options you use, although this tutorial assumes the defaults:: $ paster quickstart myapp Enter package name [myapp]: myapp Do you need authentication and authorization in this project? [yes] no ToscaWidgets is enabled by default, so you don't need to edit any configuration. To create a sample widget, edit ``myapp/controllers/root.py`` and add:: from tw.forms.samples import AddUserForm test_form = AddUserForm('mytest') In the same file, we'll also add a new controller method ``movie``, which passes the widget into the template. Add the following to the ``RootController`` class:: @expose('myapp.templates.movie') def movie(self): return dict(test_form=test_form) We now need to create this template. Create ``myapp/templates/movie.html`` as follows:: ToscaWidgets Tutorial

Welcome to the ToscaWidgets tutorial!

${test_form()} Start the app and load the ``/movie`` page; it should look like this: .. image:: test_form.png