How to use "and" operator in dtml-if
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. <dtml-if "level_in=='Development' and AUTHENTICATE_USER.has_role('Development')"> Then execute script <dtml-else> Permission Denied! </dtml-if> Thanks for any suggestion, -- Mike Tran Shufflemaster Gaming Inc.
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'])
seems like your use of and is correct , but the fact that it is AUTHENTICATED_USER , not AUTHENTICATE_USER as you wrote might have something to do with it.. :-) on or about, Wednesday, February 06, 2002, we have reason to believe that Mike Doanh Tran wrote something along the lines of : MDT> Hi All, MDT> Can anyone show me how to use the operator "and" in the tag <dtml-if> MDT> This is how i've used it but it doesn't worked for me. MDT> Zope does not give me any error when i tried to execute this code and it also MDT> does not execute the intended script. MDT> <dtml-if "level_in=='Development' and MDT> AUTHENTICATE_USER.has_role('Development')"> MDT> Then execute script MDT> <dtml-else> MDT> Permission Denied! MDT> </dtml-if> MDT> Thanks for any suggestion, MDT> -- MDT> Mike Tran MDT> Shufflemaster Gaming Inc. MDT> _______________________________________________ MDT> Zope maillist - Zope@zope.org MDT> http://lists.zope.org/mailman/listinfo/zope MDT> ** No cross posts or HTML encoding! ** MDT> (Related lists - MDT> http://lists.zope.org/mailman/listinfo/zope-announce MDT> http://lists.zope.org/mailman/listinfo/zope-dev ) -- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
On Wed, Feb 06, 2002 at 10:01:07AM +0100, Geir Bækholt wrote:
seems like your use of and is correct , but the fact that it is AUTHENTICATED_USER , not AUTHENTICATE_USER as you wrote might have something to do with it..
:-)
huh ... that should raise him a KeyError which seems not to be evaluated because the first part of the "and"-ed term is evaluated false. So go and look if you can evaluate the level_in=='Development' as true first and then you may see the KeyError exception. :) Christian -- 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'])
participants (3)
-
Christian Theune -
Geir B�kholt -
Mike Doanh Tran