[Zope] - Insert data into db with zope

Jim Fulton jim@digicool.com
Fri, 15 Jan 1999 12:15:20 +0000


FR Chalaoux wrote:
> 

(snip)


> PART2
> ---------
> Then,  I tried to insert data in my table in the same way. But it seems something
> miss to me, have you a track?
> 
> Bye, FR.
> 
> =================================================
> document_id = Insert_from_form
> =================================================
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
> <HTML>
> 
> <HEAD>
> 
> <TITLE>New Card</TITLE>
> </HEAD>
> 
> <BODY>
> 
> <FORM ACTION="insert_total_do" METHOD="POST">
> <P>Titre <INPUT TYPE="TEXT" NAME="titre_field"
> SIZE="25"></P>
> <P>Type <INPUT TYPE="TEXT" NAME="type_field"
> SIZE="25"></P>
> 
> <P><INPUT TYPE="SUBMIT" NAME="Submit"
> VALUE="Submit"><INPUT TYPE="RESET" NAME="Reset"
> VALUE="Reset">
> </FORM>
> 
> </BODY>
> 
> </HTML>
> =================================================
> 
> =================================================
> Doc_Query_id = insert_total_do
> =================================================
> <!--#var standard_html_header-->
> <!--#call "DB.insert_total(REQUEST)"-->
> OK
> <!--#var standard_html_footer-->
> 
> =================================================
> SQLmethod_id = insert_total
> =================================================
> insert into seminar (titre,type) values ('<!--#var titre_field-->','<!--#var
> type_field-->'


Note, use sqlvar, not var:

  <!--#sqlvar titre_field type=string-->
  

If you must use var, 
at least use the sql_quote attribute to get internal
quotes handled correctly:

  '<!--#var titre_field sql_quote-->'



> =================================================
> 
> =================================================
> ERRRRRRRRRRRROR
> =================================================
> Z SQL Method at /Seminar / DB / insert_total
> 
> Error, exceptions.KeyError: titre_field

Did you define titre_field and type_field as arguments
in the SQL method?

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (540) 371-6909              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.