Introduction

by Steve McMahon last modified Dec 30, 2008 05:50 PM
One of the goals of PloneFormGen is that it should be useful for simple update operations on an external database.

This tutorial covers the use of PloneFormGen to update and insert rows in a single-table SQL database.

The simple application we'll develop here would need quite a bit of polishing before you'd wish to expose it to the public, but it will demonstrate the basic techniques.

Skills required to understand this tutorial include:

  1. The ability to add an SQL database connection and Z SQL Methods via the Zope Management Interface and to understand what they do. If you've never read the Relational Database Connectivity chapter of the Zope Book, take some time now to do it; it's fundamental.
  2. Simple Python scripting via the ZMI. Read the python-based scripts portions of the Advanced Zope Scripting chapter of the Zope Book if you're new to this vital Zope/Plone development skill.

Our basic steps will be to:

  1. Add a database and table to our SQL database and create a matching form in PloneFormGen;
  2. Add a Z SQL Method to insert rows into the database and show how it can be used in PFG;
  3. Add a Z SQL Method to read a row, write a Python script wrapper and use it to fill out the fields of our form;
  4. Add a Z SQL Method to update a row, write a Python wrapper for it and the insert method and use it as a form action;
  5. Consider the security implications of the fact that the SQL access methods we just created are not part of the Plone workflow.

By the way, we'll be skipping the "D" in CRUD. Deletion is up to you.