[Zope] conditionals inside dtml-let expressions

Mitchell Model mlm@acm.org
Thu, 18 Oct 2001 12:56:02 -0400


--============_-1208698328==_ma============
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Is there a straightforward way to bind one of two values to a let 
variable depending on the value of another variable?  In C/C++/Java I 
would use the ?: operator, but Python doesn't have that.  Or should I 
just bind the variable to None then set it later with something like

<dtml-let var=None>
   <dtml-if "testvar==targetval">
     <dtml-var expr="_.set(var, 'yes')>
   <dtml-else>
     <dtml-var expr="_.set(var, 'no')>
   </dtml-if>
</dtml-let>
--============_-1208698328==_ma============
Content-Type: text/html; charset="us-ascii"

<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>conditionals inside dtml-let
expressions</title></head><body>
<div>Is there a straightforward way to bind one of two values to a let
variable depending on the value of another variable?&nbsp; In
C/C++/Java I would use the ?: operator, but Python doesn't have that.&nbsp;
Or should I just bind the variable to None then set it later with
something like</div>
<div><br></div>
<blockquote>&lt;dtml-let var=None&gt;</blockquote>
<blockquote>&nbsp; &lt;dtml-if
&quot;testvar==targetval&quot;&gt;</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; &lt;dtml-var expr=&quot;_.set(var,
'yes')&gt;</blockquote>
<blockquote>&nbsp; &lt;dtml-else&gt;</blockquote>
<blockquote>&nbsp;&nbsp;&nbsp; &lt;dtml-var expr=&quot;_.set(var,
'no')&gt;</blockquote>
<blockquote>&nbsp; &lt;/dtml-if&gt;</blockquote>
<div>&lt;/dtml-let&gt;</div>
</body>
</html>
--============_-1208698328==_ma============--