[Zope-dev] Re: local/set
Stefan Langerman
lfalse@cs.rutgers.edu
Fri, 10 Dec 1999 20:55:44 -0500
Evan Simpson <evan@4-am.com> wrote:
> "Phillip J. Eby" wrote:
>
> > Let: allows read-only variables to be computed whose values are usable
> > within a DTML nesting scope.
> >
> > Local: allows writable variables to be computed, whose values are usable
> > and changeable within a DTML nesting scope.
> >
> > Set: singleton tag that changes the value of a "local" variable, as long as
> > it was defined in the innermost surrounding "local" block.
>
> Given these use-cases, consider the following variant of Let:
>
> <dtml-let x="1+1" person: firstname=" 'fred' " weight="180">
> <dtml-var x>, <dtml-var firstname>, <dtml-var "person.weight">
> <dtml-call "person.set('weight', 185)">
> <dtml-var weight>
> </dtml-let>
>
> That is, every variable set after a colon-terminated singleton 'foo:' is also
> a mutable (through .set()) attribute of 'foo'.
>
> Cheers,
>
> Evan @ 4-am
I agree that Let and Local would be redundant. Just set would be enough:
<dtml-let x="hello"> <dtml-var x> <dtml-set x="world"> <dtml-var x> </dtml-let x>
Also note the argument in the </dtml-let x> which might make things more readable if
there are nested lets. If you just want to declare a variable (without a value), you
could
also say <dtml-let x>. And maybe we could even live without set if we extend the
use
of Let:
<dtml-let x="hello"> <dtml-var x>
<dtml-let x="world"> <dtml-var x>
</dtml-let x>
Personally, I prefer the first solution, but if we really want to avoid introducing
new
tags, just say that <dtml-let> sets the value of a local var, </dtml-let> unsets
it...
Another thing I would love to see is a clean way to pass parameters
to dtml methods, instead of putting them in REQUEST. like:
<dtml-var some_method args="arg1:val1,arg2:val2">
instead of:
<dtml-call "REQUEST.set('arg1',val1)">
<dtml-call "REQUEST.set('arg2',val2)">
<dtml-var some_method>