[Zope] How to check type of variable in DTML

Schmidt, Allen J. aschmidt@nv.cc.va.us
Wed, 8 May 2002 09:30:17 -0400


>From what I have seen, Zope does not do this. The link you sent has nothing
relating to this issue.

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.

Thanks

-Allen

-----Original Message-----
From: hans [mailto:hans@beehive.de]
Sent: Wednesday, May 08, 2002 10:22 AM
To: Schmidt, Allen J.
Cc: zope@zope.org
Subject: Re: [Zope] How to check type of variable in DTML


"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