[Zope] How to use double quotes (") in a string in a python expression in dtml

Barry Pederson barryp@medicine.nodak.edu
Thu, 21 Mar 2002 11:39:01 -0600


Oleg Broytmann wrote:
> On Thu, Mar 21, 2002 at 02:45:46PM +0100, Igor Leturia wrote:
> 
>>  I want to check in dtml if a string variable contains double quotes
>>("), so I include a python expression in a dtml-if, something like this:
>>
>>  <dtml-if "_.string.find(s,'"')<>-1">
>>
>>  Of course, this doesn't work as the dtml interpreter thinks the " is
>>the end of the python expression. But I tried it with \" also, and it
>>doesn't work.
>>
>>  Any ideas?
> 
> 
>    DTML parser is too weak. :(
> <dtml-if "_.string.find(s, _.chr(34)) <> -1">

Haven't tried this in DTML, but in a ZPT I found you could use the hex escape 
for the char, so maybe this would work:

    <dtml-if "_.string.find(s,'\x22')<>-1">

  Barry