[Zope] Checkboxes/SQL data type problem

Aseem Mohanty aseem@neurobehavioralsystems.com
Tue, 18 Jun 2002 23:26:10 -0700


when you use checkboxes with the same name or for that matter similar 
names <input name="..."> in a form, the item in the REQUEST variable is 
a list or in case of Zope a list-string of the form "['a','b','c']". 
Write a python script to convert it to a list. If you need one I can 
give it to you altho I must confess I am not an expert in Python.
AM

J.H.Whalley wrote:

>Hi,
>
>Please excuse a dumb newbie question. I've been trawling mailing list 
>archives and documentation for clues and am getting nowhere. So far I've done 
>most of what I need to do with DTML and relying on Znolk for working out 
>basic code for handling external databases, so I'm probably missing something 
>really obvious here.
>
>I'm using Zope 2.4.3 on NT4 connecting to Access databases via ZODBC DA.
>
>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?
>
>
>Relevant code:
>
>Form (DTML document - extraneous stuff cut):
>
><form action="ActionUpdateResult" method="post">
>
><dtml-in ActionListMethod>
><strong>Action:</strong> <input type="checkbox" name="action_list:int:list" 
>value="<dtml-var ejournal_id>" checked>
></dtml-in>
>
><input type="submit" value="Action selected items">
></form>
>--------------------------------------------------------
>
>
>ActionUpdateResult (DTML-document - results page):
>
><dtml-in action_list>
>   <dtml-call "ActionUpdateMethod(ejournal_id=_['sequence-item'])">
></dtml-in>
>--------------------------------------------------------
>
>
>ActionUpdateMethod (ZSQL method):
>
>Arguments:
>ejournal_id:int 
>actioned_date="<dtml-var ZopeTime fmt=%d/%m/%Y>" 
>
>
>update new_ejournals set 
>	actioned_date=<dtml-sqlvar actioned_date type=string > 
>	 where  ejournal_id=<dtml-sqlvar ejournal_id type=int> 
>--------------------------------------------------------
>
>
>TIA for any light you can shed,
>John Whalley
>
>
>--
>* John Whalley, Crewe Site Library, Manchester Metropolitan University
>* email: J.H.Whalley@mmu.ac.uk
>* Phone: (+44) 161 247 5220 (UK)
>* Usual disclaimer applies...........
>
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists - 
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
>

-- 
==================================================================
 Aseem Mohanty							   
 Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 
 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231		  	
==================================================================								  	
 "I saw `cout' being shifted "Hello world" times to the left and  
  stopped right there!!"                        -- Steve Gonedes  
==================================================================