Re: [Zope] Unless not quite the opposite of if?
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'.
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.
Dieter
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>
Curtis Maloney writes:
On Fri, 09 Jun 2000, Dieter Maurer wrote:
Curtis Maloney writes:
... dtml-unless does not work ...
... Seems that you make something wrong ...
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.
Sorry! But some problem reports are difficult to believe. I tried the following DTML-method with Zope 2.1.6: <dtml-var standard_html_header> <dtml-unless "0">should render<br></dtml-unless> <dtml-unless "1">should not render</dtml-unless> <dtml-unless "REQUEST.has_key('XXX')">should render<br></dtml-unless> <dtml-call "REQUEST.set('XXX',1)"> <dtml-unless "REQUEST.has_key('XXX')">should not render</dtml-unless> <dtml-var standard_html_footer> It worked as expected. No hint that "dtml-unless" could be faulty. Dieter
participants (2)
-
Curtis Maloney -
Dieter Maurer