[Zope3-dev] Re: RFC: TALES adapters and TAL/Tales variable namespaces

Casey Duncan casey at zope.com
Wed May 19 16:39:06 EDT 2004


On Wed, 19 May 2004 16:00:43 -0400
Jim Fulton <jim at zope.com> wrote:

> I've posted two proposals:
> 
>    http://dev.zope.org/Zope3/TALESPathExpressionAdapters

I have to say I am not found of "*", but using the parenthesis to "cast"
the variable seems fairly natural and isn't colored by completelt
different meaning in other languages.

So the example:
  tal:content="x/y*foo.bar.baz/z"

would be:
  tal:content="x/(foo.bar.baz)y/z"

Which seems reasonable. The dotted notation seems ok, but it implies
that this notation is recognized in general in path expressions which is
confusing because it isn't. If we didn't use dots then it might look
like:
  tal:content="x/(modules/foo/bar/baz)y/z"

If the thing in the parenthesis is just another path expression, that
mitigates the need for namespaces IMO. The above could then become:
  tal:define="baz modules/foo/bar/baz"
  tal:content="x/(baz)y/z"

Which seems more elegant than introducing dotted names and namespaces on
top of the adapter "cast" notation. 
 
> Proposes a mechanism for easily using adapters in TALES expressions.
> 
>    http://dev.zope.org/Zope3/ZPTVariableNamespaces
> 
> proposes a mechanism for qualifying names defined in TAL and used in
> TALES expressions.

IMO namespaces are YAGNI, and only encourage too much template
complexity. At least I am not convinced by any of the examples I have
seen here. Namespaces are hard for users to grok in general and nested
multiple namespaces even more so (multiple ZPT namespaces embedded
inside multiple XML namespaces). It may be easy for you or I to
differentiate them and keep everything straight, but I think it is a
conceptual burden especially to "casual" scripters and newbies.

If namespaces are necessary for some reason I have not seen, then I will
come out against declaring namespaces. Seems too formal for template
code.

-Casey




More information about the Zope3-dev mailing list