[Zope] Populating a form

Thomas B. Passin tpassin@mitretek.org
Fri, 26 Apr 2002 16:19:07 -0400


[McDonnell, Larry]>

>
> I see that I need to call the record from an http address and this assumes
> the users have something between their ears. I need this query to appear
on
> the screen for the users to enter. The project I am piloting is to move to
> web based forms for our factory employees to input data and if someone
wants
> to review it pull up an existing record by entering for example
> "doc_number". The user will enter this and hit a submit button. The form
> outline is what they are familiar to and I need to work on this premise.
>
> I created the input form using dreamweaver. I added the dtml statements
and
> sql methods. I can populate the database. I know this is old time stuff
> using a different environment. I am trying to move to a thin client out on
> the factory floor and eliminate buying software for each workstation.
>
> If I use my z sql query, the data is displayed in a table/record generate
by
> "manage_test" form. I guess my question is do I need to script the query
to
> return the record I am looking for and make a dtml call from the form? If
> that is the case, does anyone have a script talking to a database so I can
> see an example.
>

So you have the input working right and now you want to display reports
(existing records), right?  You have to create a dtml page (if you are using
dtml instead of ZPT) of your own for each record type.  In the page, you get
the data from the database by calling your query.  If you are using dtml,
you could start with something like

<dtml-in theZSQLQuery>

....
</dtml-in>

You do not need to use the Zope-generated reports, and you can choose any
names you want for your pages.

Look at the source of the standard report page that Zope can build for for
your query to see how to access the rows and columns.  Bear in mind that
your report page will be the action of a form sent by a user's browser -
that's how you get hold of the right query parameters to send to the query.
You also have to declare those parameters (or you can just use the REQUEST;
if so, you don't have to declare it).  You do that on the "Edit" page for
the query.

Here is a fragment of a working page I did for a project a while ago.  The
page calls a query method named "quick_look'.  "Person","Expertise",
"Office", "specific_needs", and "usage" are all column names in the result
set:

<dtml-let results=quick_look>
 <dtml-in results> <!-- loops over the rows -->
  <tr>
   <td><dtml-var Person></td><td><dtml-var Office></td>
   <td><dtml-var Expertise></td><td><dtml-var specific_needs></td>
   <td><dtml-var usage></td>
  </tr>
 </dtml-in>
</dtml-let>

Cheers,

Tom P

It's not hard.