[Zope-dev] ANN: "Let" tag available for download
Jim Fulton
jim@digicool.com
Thu, 10 Jun 1999 19:13:36 +0000
"Phillip J. Eby" wrote:
>
> Do you find nesting <!--#with "_.namespace()"--> tags too verbose? Don't
> like cluttering your REQUEST object with temporary variables? Want to get
> at weirdly named DTML variables from Python expressions without having to
> play _[] and _.render() tricks? Then check out:
>
> http://telecommunity.com/DT_Let.py
>
> It's a new tag that lets you create blocks like:
>
> <!--#in "1,2,3,4"-->
> <!--#let num=sequence-item
> index=sequence-index
> result="num*index"-->
> <!--#var num--> * <!--#var index--> = <!--#var result-->
> <!--#/let-->
> <!--#/in-->
>
> Which yields:
>
> 1 * 0 = 0
> 2 * 1 = 2
> 3 * 2 = 6
> 4 * 3 = 12
>
> Notice that quoted arguments are treated as expressions, and unquoted
> arguments are treated as DTML names. Evaluation is in sequence with the
> result of earlier assignments available to later ones. Later assignments
> can also override earlier ones, which can be helpful for longer
> step-by-step calculations. The variables thus set are in effect for the
> life of the <!--#let--> block.
>
> To use this wonderful, lifesaving tag, just stick the module somewhere that
> Python can find it, and put an "import DT_Let" somewhere in your code where
> it will get executed before you need it. Permission is hereby granted to
> the wonderful folks at DC to incorporate this into Zope. The point of
> making this was to reduce verbosity for heavy DTML scripting, though, so if
> you do put it in, *please*, *please* don't rename it to #with-namespace or
> #with-variable-values or anything like that, okay? :) Thanks.
I like it. May we include it in the Zope distribution?
Jim
--
Jim Fulton mailto:jim@digicool.com
Technical Director (888) 344-4332 Python Powered!
Digital Creations http://www.digicool.com http://www.python.org
Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.