This works: <dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname> But this doesn't: <dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]> Why is that? What does work for list access? Regards, JJ
On Wed, 7 Mar 2001, Joh Johannsen wrote:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
<dtml-var "asplit[0]"> should work. -- Joel Burton <jburton@scw.org> Director of Information Systems, Support Center of Washington
OK, I saw the answer in the list (should have read it first!) "Now" "I" "know" "when" "quotes" "are" "required" "Regards", "JJ" Joh Johannsen wrote:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
Regards,
JJ
_______________________________________________ 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 )
Joh Johannsen <jojo@farm9.com> writes:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
It's fundamental dtml, <dtml-var aname> is a shorthand for <dtml-var name="aname"> <dtml-val "asplit[0]'> is a shorthand for <dtml-var expr="asplit[0]"> you were trying to use an expression where a name was expected. HTH Siggy
Siggy Brentrup <bsb@winnegan.de> writes: [...]
<dtml-var aname> is a shorthand for <dtml-var name="aname"> <dtml-val "asplit[0]'> is a shorthand for <dtml-var expr="asplit[0]"> <dtml-var "asplit[0]"> is a shorthand for <dtml-var expr="asplit[0]">
Args, fingers faster than eyes? Sorry for the inconvenience Siggy
Siggy Brentrup wrote:
Joh Johannsen <jojo@farm9.com> writes:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
It's fundamental dtml,
<dtml-var aname> is a shorthand for <dtml-var name="aname"> <dtml-val "asplit[0]'> is a shorthand for <dtml-var expr="asplit[0]">
you were trying to use an expression where a name was expected.
yes, thanks. Not being aware of the shorthand notation, I just assumed it was Python, where you can refer to variables and list members without quotes. This "almost-Python" approach seems to confuse alot of people. What I'd really like to do with the above example is just directly embed Python: <dtml-let asplit=string.split(bigstring,'&')> <dtml-var asplit[0]> Isn't that a bit more straightforward than: <dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var "asplit[0]"> This second one requires knowing: 1. REQUEST.set (and no doubt there are alternatives for setting a variable which I'm not aware of) 2. enclosing REQUEST.set in quotes 3. single quoting variable name as the first parameter to REQUEST.set 4. NOT quoting second parameter to REQUEST.set 5. using "_." before any namespace reference (sometimes, not exactly sure when) in the second parameter to REQUEST.set 6. quoting the list reference (as opposed to NOT quoting a variable reference) It seems like python-Zope integration could be alot more transparent. JJ
You might want to look into Python Scripts (or Python Methods). They provide a really good place for string manipulation and business logic. You can make routines that you can call from DTML, letting you use each as it is advantageous to you. -- Jim Washington Joh Johannsen wrote:
Siggy Brentrup wrote:
Joh Johannsen <jojo@farm9.com> writes:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
It's fundamental dtml,
<dtml-var aname> is a shorthand for <dtml-var name="aname"> <dtml-val "asplit[0]'> is a shorthand for <dtml-var expr="asplit[0]">
you were trying to use an expression where a name was expected.
yes, thanks.
Not being aware of the shorthand notation, I just assumed it was Python, where you can refer to variables and list members without quotes.
This "almost-Python" approach seems to confuse alot of people. What I'd really like to do with the above example is just directly embed Python:
<dtml-let asplit=string.split(bigstring,'&')> <dtml-var asplit[0]>
Isn't that a bit more straightforward than:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var "asplit[0]">
This second one requires knowing:
1. REQUEST.set (and no doubt there are alternatives for setting a variable which I'm not aware of) 2. enclosing REQUEST.set in quotes 3. single quoting variable name as the first parameter to REQUEST.set 4. NOT quoting second parameter to REQUEST.set 5. using "_." before any namespace reference (sometimes, not exactly sure when) in the second parameter to REQUEST.set 6. quoting the list reference (as opposed to NOT quoting a variable reference)
It seems like python-Zope integration could be alot more transparent.
Joh Johannsen wrote:
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
asplit[0] doesn't exist as a name in DTML space; use <dtml-var "asplit[0]"> as a python expression. Not tested but should work Cyril Elkaim
other example <dtml-var "_.string.split(bigstring,'&')[0]"> AdeL irc.debian.org #zope-it Joh Johannsen wrote:
This works:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-call "REQUEST.set('aname',asplit[0])"> <dtml-var aname>
But this doesn't:
<dtml-call "REQUEST.set('asplit',_.string.split(bigstring,'&'))"> <dtml-var asplit[0]>
Why is that? What does work for list access?
Regards,
JJ
_______________________________________________ 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 )
participants (6)
-
Cyril Elkaim -
Giuseppe Masili -
Jim Washington -
Joel Burton -
Joh Johannsen -
Siggy Brentrup