[Zope] comparing two variables type="int"

Terry Hancock hancock@anansispaceworks.com
Tue, 18 Jun 2002 14:11:28 -0700


> From: Michael <mlewis@exasource.com>
> 
> Try <dtml-if expr="A == B">

Would this make a difference?
Python normally doesn't care about this whitespace, IIRC.

> Dieter Maurer wrote:
> 
> > Mike Tran writes:
> >  > I have two variables A & B whose types are "int".  What is wrong with this 
> >  > comparision?
> >  > 
> >  > (Assume A=5 and B=5)
> >  > 
> >  > <dtml-if "A==B"> 
> >  > Then do something 
> >  > </dtml-if>
> > It is nothing wrong. It must work!
> > 
> > But DTML is dangerous.
> > 
> >    Sometimes, you do not get the objects you expect.
> >    I expect that this is your true problem.

Most times I ran into a problem like this, it was
because I had inadvertently converted one or both
of the variables to a string (e.g. attempted to pass
an integer through a web request instead of a direct
call -- I often confused the action of calling a method
with an HTTP POST with calling it from another method
in Zope, despite the fact that these are actually quite
different things).

Often, doing something like:

<dtml-if expr="_.int(A)==_.int(B)">
	Conditional stuff.
</dtml-if>

would fix it.  Don't forget the pesky "_" namespace
qualification for builtins in DTML.

Terry

-- 
------------------------------------------------------
Terry Hancock
hancock@anansispaceworks.com       
Anansi Spaceworks                 
http://www.anansispaceworks.com 
P.O. Box 60583                     
Pasadena, CA 91116-6583
------------------------------------------------------