[Zope] ZPT, DTML, SQL and Forms

Colin Fox cfox@crystalcherry.com
25 Mar 2002 19:31:13 -0800


--=-PLlhpyCgOboXDlEaWYAz
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hi everyone.

I'm somewhat new to Zope, so I have what may be a stupidly simple
problem (probably is, actually).

I want to have a site that allows adding, editing & searching of various
database tables (eg. people).

To keep things consistent for the user, I'd like to use one page
template that has all the fields, and just call that template with an
add dtml method, an edit dtml method, and a search dtml method.

The part I'm having difficulty with is the connection between the ZSql
and the template - specifically, I execute a SQL function to get the
person's data, and I'd like to populate the template with it. To do
this, I need to set the 'value' field of each input type in the form.

I can set the field values in the form like this:

 <tr>
     <td><LABEL for=3D"firstname">First name: </LABEL></td>
     <td><INPUT type=3D"text" name=3D"first_name" value=3D""
          tal:attributes=3D"value request/form/first_name"
          tal:on-error=3D"string:">
     </td>
 </tr>

This works if the form has itself as an action target. But what is the
namespace for the variables returned by a ZSQL call? The column has the
same name as the field (in this case, 'first_name'). How do I access the
returned values from an ZSQL call?

Another thing I've been wondering - I can't find the documentation on
the various namespaces (here, request, etc). Where are they listed, and
when should you use one over the other?

TIA,
  Colin

--=20
Colin Fox                                       cfox@crystalcherry.com
CF Consulting Inc.                                    GPG Fingerprint:
                    D8F0 84E7 E7CC 5C6C 9982  F1A7 A3EB 6EA3 BC97 572F

--=-PLlhpyCgOboXDlEaWYAz
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA8n+uBo+tuo7yXVy8RAnIOAJ9jRhqprTlBCTxMD6bDsH5zTYtFDQCguLae
vx8G7NYqkZ+LZDLz1OLBEFk=
=HKVH
-----END PGP SIGNATURE-----

--=-PLlhpyCgOboXDlEaWYAz--