[Zope] How to check type of variable in DTML

hans hans@beehive.de
Wed, 08 May 2002 15:42:41 +0100


"Schmidt, Allen J." wrote:

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

sorry. ive seem it somewhere. try "multiple"

>
> 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.
> 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