Chapter 16.2. Form Widgets

Form Widgets contain any number of form field elements. These elements are contained in a WidgetsList that contains all the form elements you want. A WidgetsList is like a Python list, so you can append new widgets to it dynamically, but remember this list will be rendered the same way for all incoming requests. So, in general, it’s okay to create the WidgetsList pragmatically, but don’t go around changing it after you’ve instantiated a form object with it, without thinking through the thread safety issues.

You might remember our widget example from Chapter 5:

class bookmark_fields(widgets.WidgetsList): bookmark_name = widgets.TextField(validator=validators.NotEmpty) link = widgets.TextField(validator=validators.URL) ...

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.