Chapter 4.3. A Simple Form to Add Bookmark

TurboGears has lots of tools to help you build, validate, and process form data. There’s a web-based data editing tool in the TurboGears toolbox, and even an experimental FastData class to automate form creation for your model classes.

We cover each of these tools, but for now let’s create a new method to our controller to add new bookmarks and feed data to it from a simple web form. Rather than do this all in one big step, let’s start by creating a save_bookmark method in our controller that adds a predefined bookmark to the database. We set up some variables, and then create a new Bookmark object with the exact same syntax we used earlier in the chapter when we created our first bookmark through ...

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.