[Zope] How to check type of variable in DTML

Stuart Bishop zen@shangri-la.dropbear.id.au
Thu, 9 May 2002 12:31:43 +1000


On Wednesday, May 8, 2002, at 11:30  PM, Schmidt, Allen J. wrote:

> If I send in a string to a ZSQL method and the first block below is in 
> the
> WHERE clause, then it strips off the first and last letters.
>
> If I send in a list like  ['Ford','Toyota','']  then is takes the 
> [ and ]
> off and gives me the correct IN syntax.
>
>
> I need to see if the variable coming in is a list or just a string and
> branch accordingly. Maybe I am going about it all wrong but this is 
> what I
> am trying to do now.


SELECT * FROM foo_table
WHERE
	<dtml-sqltest some_parameter column=some_column_name type=nb 
multiple=true>


If I pass a string as the some_parameter parameter, the following SQL is 
generated:

SELECT * FROM foo_table
WHERE
	some_column_name = 'The string I passed, quoted nicely for me by Zope'

If I pass a list or strings, the following SQL is generated:

SELECT * FROM foo_table
WHERE
	some_column_name IN ('First string','Second string')


--
Stuart Bishop <zen@shangri-la.dropbear.id.au>
http://shangri-la.dropbear.id.au/