[Zope] Using Form data values in ZSQL Method: I must be missing something here

Howard Hansen zope@halfmagic.com
Mon, 18 Feb 2002 15:26:28 -0800


I'm certain that I'm doing something very silly here, and I've learned many
new things about Zope and databases by researching this problem, but I
haven't figured out how to make it work.

All I want to do is create forms that allow me to insert or update records
in a database.

Here's the structure I've set up:

    form: collects the form data, and when the user clicks submit, it calls:
    action_dtml_method: which calls:
         zsql_method, which modifies the database
         and tells the user what just happened

When I hit Submit, I can easily list the values from the form inside the
action_dtml_method, but zsql_method acts like it has no clue about the form
values.  It gives me the error:

    Missing input variable, field_companyname

and the traceback:

    <!--
    Traceback (innermost last):
      File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 223, in
publish_module
      File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 187, in
publish
      File /usr/lib/zope/lib/python/Zope/__init__.py, line 226, in
zpublisher_exception_hook
        (Object: dir)
      File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 171, in
publish
      File /usr/lib/zope/lib/python/ZPublisher/mapply.py, line 160, in
mapply
        (Object: company_update)
      File /usr/lib/zope/lib/python/ZPublisher/Publish.py, line 112, in
call_object
        (Object: company_update)
      File /usr/lib/zope/lib/python/OFS/DTMLMethod.py, line 195, in __call__
        (Object: company_update)
      File /usr/lib/zope/lib/python/DocumentTemplate/DT_String.py, line 546,
in __call__
        (Object: company_update)
      File /usr/lib/zope/lib/python/Shared/DC/ZRDB/DA.py, line 486, in
__call__
        (Object: sqlUpdateCompany)
      File /usr/lib/zope/lib/python/DocumentTemplate/DT_String.py, line 546,
in __call__
        (Object: &lt;string&gt;)
      File /usr/lib/zope/lib/python/Shared/DC/ZRDB/sqlvar.py, line 171, in
render
        (Object: field_companyname)
    Missing Input: (see above)
    -->


I've tried using <dtml-call zsql_method>, <dtml-with zsql_method>, <dtml-in
zsql_method>, and each of those using "zsql_method()" as well.

I could try to pass the values explicitly, but I've used acquisition very
effectively in other situations, and I'm not terribly interested in passing
29 parameters to the query.

Clearly, I'm missing something fundamental, could someone please tell me
what it is?

Thanks!

Howard Hansen
http://howard.editthispage.com