[Zope-DB] cant perform insert on mysql

Harry Wilkinson harryw@nipltd.com
Mon, 27 May 2002 12:11:15 +0100


It looks to me like you're not submitting the request containing all your 
data to the ZSQL method, just calling it.  I am not sure how dtml-call works, 
and I am not that familiar with DTML's namespace handling (I have avoided 
DTML as much as possible in favour of Python/ZPT) but perhaps the data are 
not available when you use dtml-call like that.

For a quick hack solution, if it's the dtml-call that's the problem, you 
could pass the REQUEST to the ZSQL method explicitly, something like this 
(you'll have to check the semantics, this is off the top of my head):

<dtml-call "sqlInsertRequest(REQUEST=REQUEST)">



Harry

On Monday 27 May 2002 10:47 am, Greg wrote:
> I am guessing someone has seen this or at least has some info for me.  I am
> not able to run an insert into my mysql database.  I can run a test on the
> connection object, it works just fine so I assume the db
> connection/operation is OK.  But in my Zsql method the insert does not
> work. Below are my forms used and the resulting page with the error.  I
> have tried to use separate input forms and processing pages.  I can see my
> variables passed to the new page.
>
> It seems that the sqlvar is not allowing the passed data to go through.  I
> have tried 'type="string"' as well.  I am just plain lost with this now and
> I need help!  I really want to move my web sites out of IIS and into
> Zope(on Linux), I can see it has great potential and time saving features
> for developers, but if I cant insert into a database, I am screwed!
>
> Any help is appreciated!
> Greg
>
>
> ZSQL Method------------------------sqlInsertRequest
> insert into Requests (username,rtype,req)
> values (<dtml-sqlvar username type="nb" >,<dtml-sqlvar rtype type="nb">
> ,<dtml-sqlvar req type="nb">)
>
> --------------------------------------------------------------------
> and the form I use to call the method:
>
> DTML Method------------------------------frmInsertRequest
> <dtml-var standard_html_header>
>
> <dtml-if submit>
>
> <dtml-call sqlInsertRequest>
>
> <h2>Added</h2>
>
> <dtml-else>
>
> <h2><dtml-var title_or_id> <dtml-var document_title></h2>
> <p>
> <form action="frmInsertRequest" method="post">
> <table>
> <tr><td>Username:</td> <td>
> <input type=text size=20 name="username" value="" >
> </td></tr>
> <tr><td>Type:</td><td>
> <input type=text size=20 name="rtype" value="">
> </td></tr>
> <tr><td>Request:</td><td>
> <input type=text size=20 name="req" value="">
> </td></tr>
> </table>
> <input type="submit" name="submit" value="submit">
> </form>
> </p>
> </dtml-if>
> <dtml-var standard_html_footer>
> --------------------------------------------------------------------------
> This is resulting page:
>
> Missing input variable, username
>
> Traceback (innermost last):
>   File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 150, in
> publish_module File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line
> 114, in publish File /usr/local/Zope/lib/python/Zope/__init__.py, line 159,
> in zpublisher_exception_hook (Object: Helpdesk)
>   File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 98, in
> publish File /usr/local/Zope/lib/python/ZPublisher/mapply.py, line 88, in
> mapply (Object: frmInsertRequest)
>   File /usr/local/Zope/lib/python/ZPublisher/Publish.py, line 39, in
> call_object (Object: frmInsertRequest)
>   File /usr/local/Zope/lib/python/OFS/DTMLMethod.py, line 127, in __call__
>     (Object: frmInsertRequest)
>   File /usr/local/Zope/lib/python/DocumentTemplate/DT_String.py, line 473,
> in __call__ (Object: frmInsertRequest)
>   File /usr/local/Zope/lib/python/Shared/DC/ZRDB/DA.py, line 414, in
> __call__ (Object: sqlInsertRequest)
>   File /usr/local/Zope/lib/python/DocumentTemplate/DT_String.py, line 473,
> in __call__ (Object: <string>)
>   File /usr/local/Zope/lib/python/Shared/DC/ZRDB/sqlvar.py, line 99, in
> render (Object: username)
> Missing Input: (see above)