[Zope] Populating a form

McDonnell, Larry lmcdonnell@protonenergy.com
Fri, 26 Apr 2002 15:20:22 -0400


Hi Ian,

Thanks for the reply. I know it is early there and a Friday/Saturday and
this can wait until Monday.

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.

-----Original Message-----
From: icottee@localhost.localdomain
[mailto:icottee@localhost.localdomain]On Behalf Of Ian J Cottee
Sent: Friday, April 26, 2002 1:14 PM
To: McDonnell, Larry
Cc: 'zope@zope.org'
Subject: Re: [Zope] Populating a form


Hi Larry

"McDonnell, Larry" <lmcdonnell@protonenergy.com> writes:

> I am new to the Zope environment but I have been successful. I have been
> able to add odbc database connection and through a form input information
to
> this database. Now I would like to view this information. I have set up z
> sql methods and I can see the info under the manage_test format. I would
> like to be able to re-populate my output form (its a copy of the input
form
> but without the submit). I have gone through the zope book but maybe I
> missed something. Any examples or pointer I can use, thanks.

If I understand you correctly, you want to have a form that displays
just one record on the screen? A very basic method would be to create
one ZSQL method to get your item and one DTML Document to display
it. So your SQL Method would look something like this

<params>pk</params>
SELECT CODE, DESCRIPTION, PRICE FROM MYFILE WHERE 
        ID = <dtml-sqlvar pk type=int>

Lets say that simple method is called sqlSelect

Now create a form in the same folder and it will look something like
this (untested)

<dtml-var standard_html_header>
<dtml-in sqlSelect>
   My Code Is: <dtml-var CODE null=""><br>
   My Description Is: <dtml-var DESCRIPTION null=""><br>
   My Price is: <dtml-var PRICE fmt="%3.2f" null="0.00">
</dtml-in>
<dtml-var standard_html_footer>

If that form was called view_data you can call it with something like 

http://my.web.server:8080/view_data?pk=1

Which would display the data for the record with an ID of 1. You won't
get may design awards for the interface though ;-)

If you are putting the data back into the input fields you'd have just
have stuff like 

   <input type="text" name="iDescription" value="<dtml-var DESCRIPTION
null="">">

hth

Ian 

PS It's 2am here so forgive me for any mistakes above but that should
drive you in the right direction.