[Zope] Unless not quite the opposite of if?

Curtis Maloney curtis@umd.com.au
Fri, 9 Jun 2000 14:38:29 +1000


On Fri, 09 Jun 2000, Dieter Maurer wrote:
> Curtis Maloney writes:
>  > On Thu, 08 Jun 2000, Curtis Maloney wrote:
>  > > ...
>  > > The problem is, when i test the page, it seems to pass over that that,
>  > > and go right on with the page.  So, I tried to be a little more
>  > > explicit:
>  > >
>  > > <dtml-unless "REQUEST.has_key('parmName')">
>  > >   ...
>  > > </dtml-unless>
>  > >
>  > > <dtml-if parmName>
>  > >
>  > > (as I have done in MANY cases), it always evaluates true if 'parmName'
>  > > exists in the current context.
>
> That is consistent!
>
> "unless" is equivalent to "if not".
> When "if" evaluate to "true", "unless"  will skip its body and
> vice versa.
>
> 'if var' evaluates to "true", if "var" exists and has a (Python) true
> value.
>
> Seems that your request really has a key 'parmName'.

It doesn't.  Really.  I'm certain of this.  The key was not there, and yet 
the unless was not rendered.  This is why I'm posting.  It's not working as 
it should.

I guess I'm funny like that.  I only post problems when they exist.

>
>  > And worse still,  I've now decided to use the FSSession, and the
>  > following line is evaluating true when it shouldn't:
>  >
>  > <dtml-unless "FSSession.has_key('ReturnerID')">
>  >
>  > Since no FSSession keys have been set, this should evaluate FALSE.
>
> The "FSSession.has_key('ReturnerID')" should of cause yield "false".
> This means, the "dtml-unless" body is rendered.
>

Well, this is my point.   The body was NOT being rendered.


Just to follow this,  I'm now using

<dtml-if "FSSession.has_key('ReturnerID')" >
  <normal page contents>
<dtml-else>
  <handle it otherswise.>
</dtml-if>

and it is working fine.  However, since the <handle it otherwise> stuff is a 
redirect, I'd much rather just use an unless at the start of my page.

>
> Dieter

-- 
Have a better one,
	Curtis.

<dtml-var standard_work_disclaimer>