[ZPT] RFC: TALES adapters and TAL/Tales variable namespaces
Evan Simpson
evan at 4-am.com
Wed May 19 18:20:03 EDT 2004
Jim Fulton wrote:
> I've posted two proposals:
>
> http://dev.zope.org/Zope3/TALESPathExpressionAdapters
>
> Proposes a mechanism for easily using adapters in TALES expressions.
I'm not at all clear on how the proposed mechanism is superior to the
implementation of path segment prefixes that exists in Zope 2. This
differs from the namespace proposal that you cite, in that the object
named on the left of the colon is not a namespace or adapter. It is
simply a registered name that is associated with code that interprets
the text to the right of the colon. This allows constuctions such as
"a/sequence/index:2" (a.sequence[2]), "a/bag/var:x/call:" (a.bag[x]()),
and "an/object/adapt:foo.bar" (foo.bar(an.object)).
> http://dev.zope.org/Zope3/ZPTVariableNamespaces
>
> proposes a mechanism for qualifying names defined in TAL and used in
> TALES expressions.
This would of course conflict with prefixes as currently defined, and
seems weakly motivated. I can imagine getting a similar effect with a
more consistent syntax by allowing tal:define="x/y foo" when x supports
an ITALESNamespace interface. The path "x/y/z" then does exactly what
the user would expect. A namespace "x" can be created without any new
TAL syntax by providing a built-in constructor, as in tal:define="x
namespace", that creates an empty dictionary-like object with support
with ITALESNamespace.
Cheers,
Evan @ 4-am
More information about the ZPT
mailing list