-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks to everyone for pointing me in the right direction the other day. I have a quick question regarding <dtml-if ...> (I'm up to Chapter 4 in the Zope Book right now.) If I have a URI like this: GET /foo?a=3 And the corresponding DTML contains: <dtml-if expr="a=3"> <!-- Some Junk --> </dtml-if> ....Wouldn't this evaluate the Python expression? I've tried doing: <dtml-if a=3> <!-- --> </dtml-if> But received a syntax error. So I guess my question is, I thought the expr argument brought the DTML script outside the scope of the website. I'm not trying to call any external methods. Have I completely lost it now? ;-) (Don't answer that, please.) Regards, - -- George M. Ellenburg <george@ellenburg.org> <http://www.ellenburg.org/> 3 Years and counting of being 100% Microsoft-free; and much more productive. Proud user of ASK <http://www.paganini.net/ask/>, the Active Spam Killer! - --- "Grub first, then ethics." -- Bertolt Brecht -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE82RNrFItzMEWZZdgRAlttAJwPMq3i6CHNetuL4+0/Ao3CTZ36RQCfazlw 6MaCzzcpvxh+14TjBVuigDo= =hmKr -----END PGP SIGNATURE-----
I think you want "a == 3". On Wednesday 08 May 2002 1:00 pm, George M. Ellenburg wrote:
Thanks to everyone for pointing me in the right direction the other day.
I have a quick question regarding <dtml-if ...> (I'm up to Chapter 4 in the Zope Book right now.)
If I have a URI like this: GET /foo?a=3
And the corresponding DTML contains:
<dtml-if expr="a=3"> <!-- Some Junk --> </dtml-if>
....Wouldn't this evaluate the Python expression?
I've tried doing: <dtml-if a=3> <!-- --> </dtml-if>
But received a syntax error.
So I guess my question is, I thought the expr argument brought the DTML script outside the scope of the website. I'm not trying to call any external methods.
Have I completely lost it now? ;-) (Don't answer that, please.)
Regards,
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 08 May 2002 08:05 am, Harry Wilkinson wrote:
I think you want "a == 3".
Hmm, now I'm getting: invalid parameter: " == 1", for tag <dtml-if tip == 1>, on line 16 of show_tip - -- George M. Ellenburg <george@ellenburg.org> <http://www.ellenburg.org/> 3 Years and counting of being 100% Microsoft-free; and much more productive. Proud user of ASK <http://www.paganini.net/ask/>, the Active Spam Killer! - --- "That must be wonderful! I don't understand it at all." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE82RbbFItzMEWZZdgRAsCOAJ48L02dru6mrLm1u/6pDBMrAofzxQCeKiis DSH5PVe9Kp1bCg7gdpRNh6g= =Ua6v -----END PGP SIGNATURE-----
On Wednesday 08 May 2002 1:15 pm, George M. Ellenburg wrote:
On Wednesday 08 May 2002 08:05 am, Harry Wilkinson wrote:
I think you want "a == 3".
Hmm, now I'm getting: invalid parameter: " == 1", for tag <dtml-if tip == 1>, on line 16 of show_tip
That's because you haven't quoted the 'tip == 1' bit. If you want to use Python expressions, you have to quote them: <dtml-if "tip == 1"> or, more explicitly (explicit is good): <dtml-if expr="tip == 1"> By the way, without wanting to start *another* ZPT vs DTML war, I personally hate DTML and I advise anybody starting out with templating in Zope to head down the ZPT route instead of DTML. IMO your life will be much easier in the long run :) Harry
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 08 May 2002 08:21 am, Harry Wilkinson wrote:
By the way, without wanting to start *another* ZPT vs DTML war, I personally hate DTML and I advise anybody starting out with templating in Zope to head down the ZPT route instead of DTML. IMO your life will be much easier in the long run :)
Is that a package or is that standard? I'm running 2.5.0. (swipes the ground with his foot) ... d*mn, and here I was just getting used to DTML. ;-) - -- George M. Ellenburg <george@ellenburg.org> <http://www.ellenburg.org/> 3 Years and counting of being 100% Microsoft-free; and much more productive. Proud user of ASK <http://www.paganini.net/ask/>, the Active Spam Killer! - --- Emerson's Law of Contrariness: Our chief want in life is somebody who shall make us do what we can. Having found them, we shall then hate them for it. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE82RoiFItzMEWZZdgRAicwAJoD/+iVVmRsiY6qYomBmy38YCD5IQCghtUi BrpExV9HJgmBnDBArcvhxm8= =qOD4 -----END PGP SIGNATURE-----
By the way, without wanting to start *another* ZPT vs DTML war, I personally hate DTML and I advise anybody starting out with templating in Zope to head down the ZPT route instead of DTML. IMO your life will be much easier in the long run :)
Is that a package or is that standard? I'm running 2.5.0.
(swipes the ground with his foot) ... d*mn, and here I was just getting used to DTML. ;-)
Heh ;) It's standard now, you should find 'Page Template' in the dropdown list of things you can add in the Zope management interface. For a bit of an intro: http://www.zope.org/Documentation/Articles/ZPT1 http://www.zope.org/Documentation/Articles/ZPT2 http://www.zope.org/Documentation/Articles/ZPT3
"George M. Ellenburg" wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Wednesday 08 May 2002 08:21 am, Harry Wilkinson wrote:
By the way, without wanting to start *another* ZPT vs DTML war, I personally hate DTML and I advise anybody starting out with templating in Zope to head down the ZPT route instead of DTML. IMO your life will be much easier in the long run :)
Is that a package or is that standard? I'm running 2.5.0.
(swipes the ground with his foot) ... d*mn, and here I was just getting used to DTML. ;-)
its a standard since zope 2.5. where dtml provides pseudo-html-TAGS, zpt provides pseudo-html-tag-ATTRIBUTES also explicitly named namespaces and macro-mechanism. -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
on or about, Wednesday, May 08, 2002, we have reason to believe that George M. Ellenburg wrote something along the lines of : GME> On Wednesday 08 May 2002 08:05 am, Harry Wilkinson wrote:
I think you want "a == 3".
GME> Hmm, now I'm getting: GME> invalid parameter: " == 1", for tag <dtml-if tip == 1>, on line 16 of GME> show_tip <dtml-if "tip == 1"> .. or even clearer : <dtml-if expr="tip == 1"> eveluations like this have to be done as python expressions , hence the quotes (they are really just a shorthand for expr="" , and have served to confuse many a newbie....) -- Geir Bækholt web-developer geirh@funcom.com funcom oslo | webdev-team
On 05/08/2002 02:00 PM, George M. Ellenburg wrote:
I have a quick question regarding <dtml-if ...> (I'm up to Chapter 4 in the Zope Book right now.)
If I have a URI like this: GET /foo?a=3
And the corresponding DTML contains:
<dtml-if expr="a=3"> <!-- Some Junk --> </dtml-if>
....Wouldn't this evaluate the Python expression?
I've tried doing: <dtml-if a=3> <!-- --> </dtml-if>
You should use this: <dtml-if expr="a=='3'"> <!-- blablabla --> </dtml-if> a=='3' test is a equals '3' (I think form values are always strings - not sure though) a=3 assigns the value 3 to a -- Gilles Durys
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 08 May 2002 08:19 am, Gilles Durys wrote:
You should use this: <dtml-if expr="a=='3'"> <!-- blablabla --> </dtml-if>
a=='3' test is a equals '3' (I think form values are always strings - not sure though) a=3 assigns the value 3 to a
On Wednesday 08 May 2002 09:19 am, hans wrote:
it took me some time to understand, but basically there are 2 different ways for name resolution. name=... is DTML searching, expr="..." is python searching (everything in " " is python). a name-attribute may consist only of one identifier (thats why syntax error!) (in <dtml-if name=myid>, nonexistence is treated as falsehood).
On Wednesday 08 May 2002 08:22 am, Geir Bækholt wrote:
<dtml-if "tip == 1"> .. or even clearer : <dtml-if expr="tip == 1">
eveluations like this have to be done as python expressions , hence the quotes (they are really just a shorthand for expr="" , and have served to confuse many a newbie....)
Okay, So if I understand this correctly, even though the expr is called, and it's evaluating outside the scope of the website, will Python then eventually evaluate it *in* the scope of the website (through acquisition or inheritence or whatever?) Sorry, I'm *so* not an OO programmer. ;-) Wouldn't (or couldn't) there be a name-collision if I'm passing a variable/ constant that's already defined (or reserved)? Thanks again for all your help! - -- George M. Ellenburg <george@ellenburg.org> <http://www.ellenburg.org/> 3 Years and counting of being 100% Microsoft-free; and much more productive. Proud user of ASK <http://www.paganini.net/ask/>, the Active Spam Killer! - --- "The bland leadeth the bland and they both shall fall into the kitsch." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE82RmUFItzMEWZZdgRAqoIAJ9aWbe5FeE9HygnL0fFu2YoO4BMIwCfXTvQ EhV1TTZN4vW9b/8TdYkR3K0= =onz7 -----END PGP SIGNATURE-----
"George M. Ellenburg" wrote:
On Wednesday 08 May 2002 08:19 am, Gilles Durys wrote:
You should use this: <dtml-if expr="a=='3'"> <!-- blablabla --> </dtml-if>
a=='3' test is a equals '3' (I think form values are always strings - not sure though)
not always. you may type form variables, and ZPublisher converts them for you see http://www.zope.org/Members/Zen/howto/FormVariableTypes http://www.zope.org/Members/hawkfish/radio_records
a=3 assigns the value 3 to a
On Wednesday 08 May 2002 09:19 am, hans wrote:
it took me some time to understand, but basically there are 2 different ways for name resolution. name=... is DTML searching, expr="..." is python searching (everything in " " is python). a name-attribute may consist only of one identifier (thats why syntax error!) (in <dtml-if name=myid>, nonexistence is treated as falsehood).
On Wednesday 08 May 2002 08:22 am, Geir Bækholt wrote:
<dtml-if "tip == 1"> .. or even clearer : <dtml-if expr="tip == 1">
eveluations like this have to be done as python expressions , hence the quotes (they are really just a shorthand for expr="" , and have served to confuse many a newbie....)
Okay,
So if I understand this correctly, even though the expr is called, and it's evaluating outside the scope of the website, will Python then eventually evaluate it *in* the scope of the website (through acquisition or inheritence or whatever?)
Sorry, I'm *so* not an OO programmer. ;-)
Wouldn't (or couldn't) there be a name-collision if I'm passing a variable/ constant that's already defined (or reserved)?
again: <dtml-var name="theName">: the DTML-interpreter looks up theName in the namespace. If it exists, AND is callable, it calls it and replaces w the result thereof. nonexistence raises exception. <dtml-var theName> is a shorthand. <dtml-if theName>: nonexistence is falsehood. <dtml-var expr="any-python-expression">: The DTML-interpreter lets (restricted) python evaluate this (giving python also the namespace) <dtml-var "theName"> shorthand for expr="theName" if theName is callable, it will not be called! <dtml-if "theName">: nonexistence is error ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
(I think form values are always strings - not sure though)
generally, yes. but you can type form variables and ZPublisher will convert them for you. see http://www.zope.org/Members/Zen/howto/FormVariableTypes -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
"George M. Ellenburg" wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Thanks to everyone for pointing me in the right direction the other day.
I have a quick question regarding <dtml-if ...> (I'm up to Chapter 4 in the Zope Book right now.)
If I have a URI like this: GET /foo?a=3
And the corresponding DTML contains:
<dtml-if expr="a=3"> <!-- Some Junk --> </dtml-if>
....Wouldn't this evaluate the Python expression?
it does
I've tried doing: <dtml-if a=3> <!-- --> </dtml-if>
But received a syntax error.
So I guess my question is, I thought the expr argument brought the DTML script outside the scope of the website. I'm not trying to call any external methods.
Have I completely lost it now? ;-) (Don't answer that, please.)
it took me some time to understand, but basically there are 2 different ways for name resolution. name=... is DTML searching, expr="..." is python searching (everything in " " is python). a name-attribute may consist only of one identifier (thats why syntax error!) (in <dtml-if name=myid>, nonexistence is treated as falsehood). check also http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299
participants (5)
-
Geir B�kholt -
George M. Ellenburg -
Gilles Durys -
hans -
Harry Wilkinson