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

Casey Duncan casey at zope.com
Fri May 21 12:42:21 EDT 2004


On Fri, 21 May 2004 09:07:24 -0400
Jim Fulton <jim at zope.com> wrote:

> Jim Fulton wrote:
> > I've posted two proposals:
> > 
> >   http://dev.zope.org/Zope3/TALESPathExpressionAdapters
> > 
> > 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.
> 
> Based on initial comments, I've retracted ZPTVariableNamespaces and
> updated:
> 
>    http://dev.zope.org/Zope3/TALESPathExpressionAdapters
> 
> I've thrown out a few more spellings for adapter use:
> 
>    ob->adaptername      context->dc/title

Hmm, C style, kinda nice, except the use of angle brakets might make
like difficult. It really is hard for me to see the intended order of
execution of this as well. It reads "context to dublin core, get title".
Having dublin core go first makes more sense to me so it would read
"with the dublin core of context, get title". The cast notation gives
you that.

>    ob~adaptername       context~dc/title

Don't like the tilde or the order.
 
>    ob[adaptername]      context[dc]/title

This seems more readable then the above two, but I think it is too
easily confused with python expressions using __getitem__.
 
> Of course, Steve suggested:
> 
>    ob:adaptername       context:dc/title

This really doesn't make sense. To me it reads "In the namespace of
context get the title of dublin core". To me that should be:

ob/adaptername:attribute  context/dc:title

Where it would read "from context get the dublin core title". In this
case dublin core really is like a namespace. Unfortunately I know this
can't work semantically, so back to the cast syntax...
 
> So far the cast syntax seems to be the most popular:
> 
>    (adaptername)ob      (dc)context/title

Yup, still like it.
 
> with one dissension. :)
> 
> One disadvantage I see with the cast notation is that it's
> a bit jarring in:
> 
>    a/b/(adapter)c/d
> 
> as the adapter is applied to a/b/c. The order just doesn't
> seem quite right.

It's all in the eye of the beholder I guess. This says to me "d of c
(modified by adapter) of b of a".

> I'd love to get more feedback or suggestions for the syntax.
> 
> As far as in-template definition, I'd like to borrow from Evan's
> work and allow 'adapter' to be used like 'local' or 'global' in
> tal:define:
> 
>    tal:define="adapter dc modules/zope.app.dublincore/IZopeDublinCore"

I like that much more than namespaces. I still wonder if its necessary
especially if the cast notation is just another path (i.e., not a
special adapter namespace).

-Casey




More information about the Zope3-dev mailing list