Home arrow Zope arrow Form Processing With Zope

Form Processing With Zope

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

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
The thing about Zope is, everyone wants to use it, but most people don't know where to start.

Take, for example, something as simple as building a feedback form. For a PHP or Perl developer, this is a doddle, requiring no more than a couple hours of development time (OK, OK, a little more if it requires complex validation or processing). Building a feedback form in PHP or Perl is neither scary or intimidating; in fact, it's one of the most fundamental things a Web developer needs to know to consider himself even reasonably proficient in the language.

Put that same PHP or Perl developer on a Zope-based platform, however, and the sweat will really start trickling. Zope's object-oriented approach to everything tends to confuse even the most versatile PHP or Perl programmer, and you can expect that one hour to telescope into a couple of days, as our fearless programmer struggles to master the intricacies of Zope objects, variables and methods.

In case you ever find yourself in this situation, you're going to be glad you found this article. Over the next few pages, I'm going to give you a broad overview of the process of building and processing Zope forms, demonstrating how simple and painless the process really is.

I'll be assuming that you know the basics of Zope - variables, and the like - and that you have a Zope 2.50 system up and running. {mospagebreak title=Making New Friends} We'll start with something simple, a form with three fields and a form processor that displays the data entered into the form.

The first step is to create a couple of DTML Document objects (via the Zope Management Interface, usually available at http://your_zope_server:8080/your_folder/manage) to represent these two items. I've called them Form and FormProcessor respectively; feel free to name them whatever you want.

First, let's look at the Form object:

<dtml-var standard_html_header> <form action="FormProcessor" method="POST"> Species: <br> <input name="species"> <p> Home planet: <br> <input name="planet"> <p> Distance (light years) from Earth: <br> <input name="distance"> <p> <input type="Submit" value="Beam Me Up, Scotty"> </form> <dtml-var standard_html_footer>
This isn't very hard to read, even if you've never worked with Zope before. It's a standard HTML form, with DTML statements embedded within it (much like a PHP script, which has PHP commands embedded within the markup).

If you have some familiarity with Zope, you'll already know about the HTML header and footer objects; they are generic objects that can be used to place a standard header and footer on every page. Enclosed within these is a regular HTML form, albeit one which references another DTML Document when submitted. This DTML Document is named FormProcessor, and it's going to handle the task of processing the data entered into the form by the user.

<form action="FormProcessor" method="POST"> ... </form>
Here's what the form looks like:



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ZOPE ARTICLES

- 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: