In case you want to see what values are being passed back and forth between the Form and FormProcessor, you can simply display the contents of the REQUEST namespace. Take a look at the form processor below for an understanding of what this means:
Now, when you submit a form to this FormProcessor object, you'll see something
like this:
The REQUEST namespace contains a whole bunch of environment and Zope variables that you can use for your own dark purposes. These include, among others, the standard variables HTTP_USER_AGENT, HTTP_REFERER and PATH_INFO, Zope-specific variables like PUBLISHED, SERVER_URL, AUTHENTICATED_USER and URL0, and cookie and session data.
This ability to access form variables in this manner brings up another interesting item. Thus far, I've been creating individual Form and FormProcessor objects. However, it's also possible to create a combined object, simply by testing for the presence or absence of the "submit" variable.
In order to better understand this, create a new DTML Document named "DualPurposeForm" and add the following DTML code to it:
<dtml-var standard_html_header>
<dtml-if submit>
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-else submit>
<form action="DualPurposeForm" method="POST">
Species:
<br>
<input
name="species:ignore-empty">
<p>
Home planet:
<br>
<input name="planet:ignore-empty">
<p>
Distance
(light years) from Earth:
<br>
<input name="distance:ignore-empty">
<p>
<input
type="Submit" name="submit" value="Beam Me Up, Scotty"> </form>
</dtml-if>
<dtml-var
standard_html_footer>
In this case, the DTML "if" test will first check to see if the "submit" form
variable exists. If it does, it implies that the form has been submitted, and the second half of the script, the actual form processor, comes into play. If it doesn't, it implies that the form has not yet been submitted, and so the initial, empty form is displayed.
This technique makes it possible to reduce the number of objects used, and perhaps make your Zope object collection easier to handle.
There are a couple of other things you could do to the form object above. First, you could replace the object name in the form's ACTION attribute
<form action="DualPurposeForm" method="POST">
with the special Zope variable "URL0".
<form action=<dtml-var URL0> method="POST">
URL0 is a Zope variable which always holds the name of the current URL (you'll
see it in the list of variables displayed within the REQUEST namespace). Using this built-in variable covers you in case you need to change the object name in future. You might also want to wrap the "if" test within a namespace localizer - for example, <dtml-with> - in order to ensure that Zope checks the REQUEST namespace for the "submit" variable first, rather than any other namespace that exist.