You are not logged in Log in Join
You are here: Home » Members » Martijn Faassen's Page » ZFormulator » ZFormulator Info » View Document

Log in
Name

Password

 

ZFormulator Info

ZFormulator

What is it, briefly?

From the Zope user's point of view, ZFormulator is a Zope product that helps you with the production of HTML forms and their processing. From the developer's point of view, it is also a Python framework in which new form elements (fields) can be fairly easily created.

Why ZFormulator?

Making HTML forms is, to me, a pain. Even though Zope alleviates some of the difficulties that you face in writing CGI-scripts, you still need to think about too many things at once. Let's analyze what a Zope form that adds records to a database needs:

  • HTML describing the form.
  • optional JavaScript client-side validation.
  • server-side valiation; either in DTML or an external/python method.
  • Possibly some server-side preprocessing of form data.
  • a ZSQL method with an SQL insert statement.
  • the database table that is being inserted to.
  • a feedback page.

Each of these isn't very difficult to make. What is difficult is to keep them all in sync; the form layout uses field names that are then accessed in the validation, they return in the SQL insert statement, and they return in the database. Often they return in the feedback page as well. A typo is some of these systems is easy to make. And now add a new field to the form...

ZFormulator is my attempt to try to alleviate some of these difficulties.

What does it do?

Currently, ZFormulator assists primarily in the form description and validation parts. Some preprocessing also takes place. There are also some experimental facilities to help with the database part.

A ZFormulatorForm is a folderish container in which you can add a variety of formulator fields, such as IntegerField, StringField and ListField. These fields have a number of properties that influence how the field is displayed on a form, and what kind of validation and processing takes place after the form is submitted. It is also possible to define the messages that are displayed when validation goes wrong.

What is its current status?

While ZFormulator is currently being developed and many parts may change, I do believe that its core system is ready for other people to play with it. I myself will start using it for actual end-user forms shortly, but I wouldn't recommend this to others yet unless you're a Zope/Python-hacker willing to dive in when it goes wrong.

How do I come in?

No extensive knowledge of Python is necessary to play with ZFormulator; it's fully accessible from Zope's management interface. I'd love to get bug reports and comments from end users!

If you are a Zope/Python hacker I'd love to hear comments on the implementation as well. There are several parts of the implementation that could be improved so feel free to help me out with it! Well, I can always hope, can't I? It's also not too hard to create your own new field types for ZFormulator. If you do, be sure to send it to me. Read the next section!

Developer Info

ZFormulator resides in lib/python/Products/ZFormulator. As you will note, that directory is crowded, but don't let that scare you. These are the core .py files:

Field.py

You derive your own field classes from the Field class defined in this one. Most of ZFormulator consists of child classes of Field.

FieldSheet.py

ZFormulator eats its own dogfood; the edit screens in ZFormulator fields are implemented with ZFormulator itself! The edit screens are implemented by classes that derive from FieldSheet.

Form.py

A container Folderish object that can contain fields. Lots of Zope hackery here; I could need some help on some of it...

__init__.py

Here you register new fields that can added to ZFormulatorForms. It is fairly easy thanks to the Zope hackery in Form.py

Utils.py

Contains just one simple support function to easily create html_tags from Python.

All the other .py files derive either from Field or from FieldSheet. They form the following inheritance hierarchy:

  • Field
    • BasicField (simple field used for testing)
    • StringBaseField (base class for input type=text fields)
      • StringField (string input field)
      • IntegerField (integer input field)
      • RangedIntegerField (integer field with extra range validation)
    • TextareaField (multiple line text input)
      • ListDataTextareaField (used in edit sheets of ListField and RadioField)
    • CheckboxField (checkbox)
    • RadioField (radio buttons; still not satisfied with its interface)

Both Field and Sheet derived classes follow this same inheritance hierarchy independently.

More information is contained in the source.