Home arrow Zope arrow Page 4 - Form Processing With Zope

Running On Empty - Zope

Ever wondered how to create and process HTML forms in the Zope environment? Relax. It's simpler than you think.

  1. Form Processing With Zope
  2. Driving Under The Influence
  3. Stringing Things Along
  4. Running On Empty
  5. In The Raw
  6. You've Got Mail!
  7. Endgame
By: Team Melonfire, (c) Melonfire
Rating: starstarstarstarstar / 13
February 26, 2002

print this article


Finally, the "ignore_empty" directive tells Zope to ignore the form variable (exclude it from the variable space) if it's left empty. Here's an example:

<dtml-var standard_html_header> <form action="FormProcessor" method="POST"> Species: <br> <input name="species:string:ignore_empty"> <p> Home planet: <br> <input name="planet:ignore_empty"> <p> Distance (light years) from Earth: <br> <input name="distance:int:ignore_empty "> <p> <input type="Submit" value="Beam Me Up, Scotty"> </form> <dtml-var standard_html_footer>
In this case, if any of the fields are left empty and the form is submitted to the FormProcessor object, the corresponding DTML variable will never come into existence. Consequently, the FormProcessor object (which, you will remember, references each of these variables) will raise a KeyError when it attempts to access this non-existent variable.

Here's what it looks like:

Don't like this? You can fix it by telling Zope what to do if it encounters a missing variable by adding the "missing" attribute to the variable call in the form processor. Take a look at the new, improved FormProcessor:

<dtml-var standard_html_header> Welcome to Earth, <b><dtml-var species missing="Alien"></b> from the planet <b><dtml-var planet missing="Zorgo"></b>. <p> How was your journey? Travelling <b><dtml-var distance missing="so many"></b> light years must be quite a shock to the system. Why don't you relax and have a drink? <dtml-var standard_html_footer>
The "missing" attribute sets a default value for the variable in the event that Zope cannot find it, in an attempt to avoid those ugly error messages.

>>> More Zope Articles          >>> More By Team Melonfire, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Creating Zope Products
- Plone Content Types With Archetypes
- Flat User Management in Zope
- Creating Basic Zope Applications
- Getting started with Zope for Linux and Sola...
- ZPT Basics (part 4)
- ZPT Basics (part 3)
- ZPT Basics (part 2)
- ZPT Basics (part 1)
- Exception Handling In DTML
- DTML Basics (part 4)
- DTML Basics (part 3)
- DTML Basics (part 2)
- DTML Basics (part 1)
- Using Zope With Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: