[Zope] Checkboxes/SQL data type problem

Dieter Maurer dieter@handshake.de
Wed, 19 Jun 2002 20:27:07 +0200


J.H.Whalley writes:
 > ...
 > I'm having trouble updating a set of records in an external DB, selecting the 
 > records using checkboxes on a form. Code is below.
 > 
 > The form appears to be producing the expected list of integers which are the 
 > record ids which need updating: if I get the results page to just display 
 > action_list it comes out as [15, 18] etc.
 > 
 > ActionUpdateMethod works fine when I test it with a single record number.
 > 
 > The results page should iterate over the list of record ids and update each 
 > record in turn.
 > 
 > What actually happens is I get an error message:
 > 
 > Error Type: sql.error
 > Error Value: ('22005', -3030, '[Microsoft][ODBC Microsoft Access Driver] Data 
 > type mismatch in criteria expression.')
 > 
 > Which looks like it isn't an integer which is getting passed via the SQL. Yet 
 > as far as I can see, the list is a list of integers, the ZSQL argument tells 
 > it it's an integer and the sqlvar tag tells it it's an integer.
 > 
 > What am I doing wrong?
You know that all parameters passed from an HTML form are strings
in the first place. Thus, what looks like a list of integers is
probably a single string that just looks like a list.

You can use type suffixes in form variable names to tell Zope
how to convert and pack HTML form data. For example, to get
a list of integers, you can have:

  <input name="recno:int:list" ...>
  <input name="recno:int:list" ...>

For details, see

  <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>



Dieter