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

Eric Walstad eric@ericwalstad.com
Mon, 18 Feb 2002 22:21:06 -0800


Hi Howard.

It looks like your ZSQL method is not getting the form data it needs. 
Like you mentioned, you could pass those parameters explicitly when you 
call the the ZSQL method, or you could pass the REQUEST object to the 
ZSQL method:

<dtml-call "zsql_method(companyname=companyname, 
companyphone=companyphone, etc to the 29th parameter)">
or
<dtml-call "zsql_method(REQUEST)">
Hey, you may want to try something like this - It might work and would 
not have to pass so much stuff to the ZSQL method:
<dtml-call "zsql_method(form)">

I'm guessing it's more efficient to pass just the parameters the ZSQL 
method will need, but it is a pain to pass all 29 of them!

I hope that helps,

Eric.

Howard Hansen wrote:
> 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