[Zope] Syntax: Learning from JSP's problems

Michael Bernstein webmaven@lvcm.com
Sun, 20 Feb 2000 01:57:16 +0000


Tres Seaver wrote:
> 
> Michael Bernstein <webmaven@lvcm.com> wrote:
> 
> <snip>
> 
> > The one thing that DTML lacks is a simpler way of passing parameters to
> > methods. I would suggest allowing syntax such as <dtml-tag a
> > name="&value;"> to pass name/value pairs into methods (including python
> > methods) letting the target methods worry about validating incoming
> > parameters and default values. this would be much clearer than using the
> > current REQUEST syntax.
> 
> We could perhaps hack the var tag to pass along any non-standard attributes as
> keyword arguments:
> 
>   <dtml-var myMethod foo="bar"> # inject foo="bar" into myMethod's namespace
> 
> Of course, then we have to escape the standard attributes used by the var tag
> itself, or else decorate all the "keyword" attributes:
> 
>   <dtml-var myMethod dtml:foo="bar">
> 
> Such a syntax would remove most of the need for the expr="" stuff, which
> requires that unintuitive '( _.None, _, ...)' bit.  It replaces some uses of the
> let tag, too, although I often have the let active across a whole method.

I would actually argue against messing with the <dtml-var foo> syntax.
In my suggestion, I was advocating the creation of a new <dtml-tag
foo="&bar;"> syntax for the express (and sole) purpose of passing in
name/value pairs (particularly dynamic/acquired values). using a new tag
syntax is a bit cleaner, and it has the advantage of assuming that all
attributes are meant to be passed into the method.

CFML (Cold Fusion Markup Language) has another interesting feature:
Multiple namespaces.

You can easily identify which method was used to pass a name/value pair
into a CFML template: Through the URL string, posted from a form, or
passed in as a tag atribute/value. This allows you to either add
conditional logic to deal with each instance separately, or you can use
this as a form of overloading the variable to allow identical handling
regardless of how the data was passed in.

In other words you can just refer to 'foo' or you can refer to
'URL.foo', 'FORM.foo', etc. using conditional logic to detect the
presence and value of each.

HTH,

Michael.