.. _tg1_app_example: TurboGears 1 ============ This tutorial assumes basic familiarity with TurboGears 1. Beginners should read the TurboGears `Wiki20 tutorial`_. The tutorial was developed using TurboGears 1.0.8. .. _Wiki20 tutorial: http://docs.turbogears.org/1.0/Wiki20/Page1 First, quickstart an app using the standard approach. It doesn't really matter what options you use, although this tutorial assumes the defaults:: $ tg-admin quickstart myapp Enter package name [myapp]: Do you need Identity (usernames/passwords) in this project? [no] To enable ToscaWidgets, edit ``myapp/config/app.cfg`` and add the following line:: toscawidgets.on = True To create a sample widget, edit ``myapp/controllers.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 ``Root`` 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.kid`` 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 Troubleshooting --------------- If you encounter this error:: TypeError: No object (name: ToscaWidgets per-request storage) has been registered for this thread Ensure you have the latest version of ToscaWidgets installed, and that ``toscawidget.on = True`` is specified in the configuration. If you encounter this error:: ValueError: need more than 2 values to unpack Make sure you have the latest version of Genshi installed. You may also need to specify this in you configuration:: tg.defaultview = 'genshi'