How to check type of variable in DTML
I am passing a variable to a ZSQL method and I need to check whether its a string or a list before it is part of a WHERE statement. How can I check this? <dtml-if mk> CMAKE IN ( <dtml-var "mk[1:-1}"> ) </dtml-if> This works well if its a list but blows up if just a string. Needs to be like this: <dtml-if mk is_A_list> CMAKE IN ( <dtml-var "mk[1:-1}"> ) <dtml-else> <dtml-var sqltest mk column=CMAKE type=nb optional> </dtml-if> Thanks -Allen
"Schmidt, Allen J." wrote:
I am passing a variable to a ZSQL method and I need to check whether its a string or a list before it is part of a WHERE statement. How can I check this?
you dont need to. Zope can do this for you. especially <dtml-sqlvar ...> and <dtml-sqltest> see http://www.zope.org/Members/jshell/ZSQLMethods-InsertingData
<dtml-if mk> CMAKE IN ( <dtml-var "mk[1:-1}"> ) </dtml-if>
This works well if its a list but blows up if just a string. Needs to be like this:
<dtml-if mk is_A_list> CMAKE IN ( <dtml-var "mk[1:-1}"> ) <dtml-else> <dtml-var sqltest mk column=CMAKE type=nb optional> </dtml-if>
-- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
Schmidt, Allen J. writes:
.... You can use the function "same_type". As the name suggests, it takes two arguments and returns whether they have the same type.
You use it, e.g., like "same_type(my_var,'')" (to test whether "my_var" contains a string). Dieter
participants (3)
-
Dieter Maurer -
hans -
Schmidt, Allen J.