[Zope] How to use "and" operator in dtml-if

Christian Theune ct@gocept.com
Wed, 6 Feb 2002 09:48:03 +0100


Hi.

On Tue, Feb 05, 2002 at 04:34:16PM -0700, Mike Doanh Tran wrote:
> Hi All,
> 
> Can anyone show me how to use the operator "and" in the tag <dtml-if>
> This is how i've used it but it doesn't worked for me.
> Zope does not give me any error when i tried to execute this code and it also 
> does not execute the intended script.

Your us of "and" is correct, as i see. The dtml-if awaits a 
correct python expression, that is evaluated to a boolean(compatible) value.

Like:

>>> 1 and 1
1
>>> 1 and 0
0
>>> 0 and 1
0
>>> 0 and 0
0
>>> 


So if your get "Permission denied" you know that your expression evaluated to
something thats 0 in boolean aka FALSE. (A nonempty string is also a boolean TRUE
equivalent in python.)

> 
> <dtml-if "level_in=='Development' and   	
> AUTHENTICATE_USER.has_role('Development')">
> Then execute script 
> <dtml-else>
> Permission Denied!
> </dtml-if>
> 
> Thanks for any suggestion,
> 

-- 
Christian Theune - ct@gocept.com
gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt
tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981

reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])