Is Zope syntax inconsistent ?
I've hit the 'Zope Wall' again ! Can anyone explain why <dtml-if expr="AUTHENTICATED_USER=='zope'"> ZOPE ! <dtml-else> NOT ZOPE ! </dtml-if> <dtml-var AUTHENTICATED_USER> <br> Displays NOT ZOPE ! zope While this <dtml-if expr="tune_id=='Reel'"> REEL ! <dtml-else> NOT REEL ! </dtml-if> <dtml-var tune_id> Displays REEL ! reel Which is what I expected ! Richard Moon richard@dcs.co.uk
Richard, The equality check on AUTHENTICATED_USER will always fail because your comparing an object with a string. You need soemthiong more like : <dtml-if expr="AUTHENTICATED_USER.getUserName()=='zope'"> hth Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Richard Moon" <richard@dcs.co.uk> To: <zope@zope.org> Sent: Friday, March 10, 2000 9:13 AM Subject: [Zope] Is Zope syntax inconsistent ?
I've hit the 'Zope Wall' again ! Can anyone explain why
<dtml-if expr="AUTHENTICATED_USER=='zope'"> ZOPE ! <dtml-else> NOT ZOPE ! </dtml-if> <dtml-var AUTHENTICATED_USER> <br>
Displays
NOT ZOPE ! zope
While this <dtml-if expr="tune_id=='Reel'"> REEL ! <dtml-else> NOT REEL ! </dtml-if> <dtml-var tune_id>
Displays
REEL ! reel
Which is what I expected !
Richard Moon richard@dcs.co.uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
or <dtml-if expr="_.str(AUTHENTICATED_USER)=='zope'"> ----- Original Message ----- From: Phil Harris <phil.harris@zope.co.uk> To: <zope@zope.org>; Richard Moon <richard@dcs.co.uk> Sent: Friday, March 10, 2000 7:08 AM Subject: Re: [Zope] Is Zope syntax inconsistent ? Richard, The equality check on AUTHENTICATED_USER will always fail because your comparing an object with a string. You need soemthiong more like : <dtml-if expr="AUTHENTICATED_USER.getUserName()=='zope'"> hth Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Richard Moon" <richard@dcs.co.uk> To: <zope@zope.org> Sent: Friday, March 10, 2000 9:13 AM Subject: [Zope] Is Zope syntax inconsistent ?
I've hit the 'Zope Wall' again ! Can anyone explain why
<dtml-if expr="AUTHENTICATED_USER=='zope'"> ZOPE ! <dtml-else> NOT ZOPE ! </dtml-if> <dtml-var AUTHENTICATED_USER> <br>
Displays
NOT ZOPE ! zope
While this <dtml-if expr="tune_id=='Reel'"> REEL ! <dtml-else> NOT REEL ! </dtml-if> <dtml-var tune_id>
Displays
REEL ! reel
Which is what I expected !
Richard Moon richard@dcs.co.uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks for solving the immediate problem Phil - another UK Zopista - there's a few of you out there ! I think I've had help from all of you in turn :-) However I think this reveals a basic problem with the syntax which is causing me grief and presumably there are others like me out there. I would expect an object to behave consistently wherever it was used - so if it renders/returns/evaluates to 'zope' inside a dtml-var I would expect it equally to render/return/evaluate to 'zope' inside a dtml-if. If it doesn't then surely we have an inconsistent syntax. How do we know how any object is going to behave inside a dtml tag ? Any comments ? At 13:08 10/03/00 +0000, you wrote:
Richard,
The equality check on AUTHENTICATED_USER will always fail because your comparing an object with a string.
You need soemthiong more like :
<dtml-if expr="AUTHENTICATED_USER.getUserName()=='zope'">
hth
Phil phil.harris@zope.co.uk
----- Original Message ----- From: "Richard Moon" <richard@dcs.co.uk> To: <zope@zope.org> Sent: Friday, March 10, 2000 9:13 AM Subject: [Zope] Is Zope syntax inconsistent ?
I've hit the 'Zope Wall' again ! Can anyone explain why
<dtml-if expr="AUTHENTICATED_USER=='zope'"> ZOPE ! <dtml-else> NOT ZOPE ! </dtml-if> <dtml-var AUTHENTICATED_USER> <br>
Displays
NOT ZOPE ! zope
While this <dtml-if expr="tune_id=='Reel'"> REEL ! <dtml-else> NOT REEL ! </dtml-if> <dtml-var tune_id>
Displays
REEL ! reel
Which is what I expected !
Richard Moon richard@dcs.co.uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Richard Moon richard@dcs.co.uk
Richard, As someone earlier today on the list said, "if it's in quotes it's python" (or something similar). Basically Python rules apply when using any expressions in zope dtml-var and other tags. Well, that's how I think of it. Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Richard Moon" <richard@dcs.co.uk> To: <Zope@zope.org> Sent: Friday, March 10, 2000 2:28 PM Subject: Re: [Zope] Is Zope syntax inconsistent ?
Thanks for solving the immediate problem Phil - another UK Zopista - there's a few of you out there ! I think I've had help from all of you in turn :-)
However I think this reveals a basic problem with the syntax which is causing me grief and presumably there are others like me out there.
I would expect an object to behave consistently wherever it was used - so if it renders/returns/evaluates to 'zope' inside a dtml-var I would expect it equally to render/return/evaluate to 'zope' inside a dtml-if.
If it doesn't then surely we have an inconsistent syntax. How do we know how any object is going to behave inside a dtml tag ?
Any comments ?
At 13:08 10/03/00 +0000, you wrote:
Richard,
The equality check on AUTHENTICATED_USER will always fail because your comparing an object with a string.
You need soemthiong more like :
<dtml-if expr="AUTHENTICATED_USER.getUserName()=='zope'">
hth
Phil phil.harris@zope.co.uk
----- Original Message ----- From: "Richard Moon" <richard@dcs.co.uk> To: <zope@zope.org> Sent: Friday, March 10, 2000 9:13 AM Subject: [Zope] Is Zope syntax inconsistent ?
I've hit the 'Zope Wall' again ! Can anyone explain why
<dtml-if expr="AUTHENTICATED_USER=='zope'"> ZOPE ! <dtml-else> NOT ZOPE ! </dtml-if> <dtml-var AUTHENTICATED_USER> <br>
Displays
NOT ZOPE ! zope
While this <dtml-if expr="tune_id=='Reel'"> REEL ! <dtml-else> NOT REEL ! </dtml-if> <dtml-var tune_id>
Displays
REEL ! reel
Which is what I expected !
Richard Moon richard@dcs.co.uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Richard Moon richard@dcs.co.uk
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Fri, 10 Mar 2000, Phil Harris wrote:
As someone earlier today on the list said, "if it's in quotes it's python" (or something similar).
Basically Python rules apply when using any expressions in zope dtml-var and other tags.
I still think it's an inconsistent syntax. It should be possible (by overriding __coerce__, I think? I haven't had time to look this up yet) to make the == operator do something different. AUTHENTICATED_USER is often used as a string (at least what I've seen of it ...) Also, "if it's in quotes it's in python", why do I need to do _.str()? why does dir() not work? It seems like some pretty horribly munged sort of python...
I would expect an object to behave consistently wherever it was used - so if it renders/returns/evaluates to 'zope' inside a dtml-var I would expect it equally to render/return/evaluate to 'zope' inside a dtml-if.
If it doesn't then surely we have an inconsistent syntax. How do we know how any object is going to behave inside a dtml tag ?
______ __ __ _____ _ _ | ____ | \_/ |_____] |_____| |_____| |_____ | | | | @ t w i s t e d m a t r i x . c o m http://www.twistedmatrix.com/~glyph/
Glyph Lefkowitz wrote:
On Fri, 10 Mar 2000, Phil Harris wrote:
As someone earlier today on the list said, "if it's in quotes it's python" (or something similar).
Basically Python rules apply when using any expressions in zope dtml-var and other tags.
I still think it's an inconsistent syntax. It should be possible (by overriding __coerce__, I think? I haven't had time to look this up yet) to make the == operator do something different. AUTHENTICATED_USER is often used as a string (at least what I've seen of it ...)
It's never used as a string because it is not a string. You can't use the word 'string' unless you are talking about python expressions. DTML does not have types, you must rely on python's expression machinery to get down to thinking about the types of objects.
Also, "if it's in quotes it's in python", why do I need to do _.str()? why does dir() not work? It seems like some pretty horribly munged sort of python...
This is for security reasons. We've overridden many of the built-in functions like str and dir with our own so that DTML programmers cannot do mean and nasty things, intentionally or unintentionally, from DTML. -Michel
Richard Moon wrote:
Thanks for solving the immediate problem Phil - another UK Zopista - there's a few of you out there ! I think I've had help from all of you in turn :-)
However I think this reveals a basic problem with the syntax which is causing me grief and presumably there are others like me out there.
I would expect an object to behave consistently wherever it was used - so if it renders/returns/evaluates to 'zope' inside a dtml-var I would expect it equally to render/return/evaluate to 'zope' inside a dtml-if.
If it doesn't then surely we have an inconsistent syntax. How do we know how any object is going to behave inside a dtml tag ?
It is not inconsistent because all things behave consistently within quotes and consistently without quotes. You just have to know the rules of each case. Granted, it's not pretty, but it's consistent. -Michel
participants (5)
-
Glyph Lefkowitz -
Jim Sanford -
Michel Pelletier -
Phil Harris -
Richard Moon