Re: [Zope] Syntax: Learning from JSP's problems
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. -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com
Just brainstorming here... feel free to slam on this... :) Tres Seaver wrote:
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
What about: <dtml-var myMethod(foo="bar")> Advantages: + Uses already well-known python syntax. Programmers don't have to learn another. It's meaning is readily apparent. + Makes it visually clear that foo "belongs to" myMethod and not dtml-var. + Removes the need to specially escape dtml-var names. Disadvantages: - Deviates from the current xml-like syntax. But then again, so does the token "myMethod" hanging out in the middle of a tag. - Robb
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.
participants (3)
-
Michael Bernstein -
Robb Shecter -
Tres Seaver