[ZPT] v2 of Path Prefixes in CVS
Evan Simpson
evan at 4-am.com
Fri Aug 29 14:39:10 EDT 2003
I've just checked in a major revamp of evan-pathprefix-branch, which
adds some tests (that all pass!), and the ability to define prefixes
other than the builtins.
After a private conversation with Shane, I've settled on the following
syntax for defining prefixes:
tal:define="prefix {name} {pexpr}"
That is, I've added a 'prefix' scope qualifier, similar to the existing
'local' and 'global'. Unlike 'local' and 'global', 'prefix' causes
tal:define to operate on the prefix namespace, and to use a restricted
set of prefix expression types rather than the normal range of TALES
expression types. This means that only two expression types are
currently available:
tal:define="prefix i builtin:item"
tal:define="prefix n ext:PageTemplates.NumericConversions"
The 'builtin' type allows you to define aliases for builtin prefix
types, while 'ext' provides access to additional types defined by
trusted filesystem code. The second example defines 'n' as the sample
prefix defined in Products/PageTemplates/ExtSample.py.
In the future, I'd like to allow Path Expressions as a prefix expression
type, with the purpose of supporting libraries of simple functions
within ZODB Folders, like so:
<div tal:define="prefix my here/zptlib"
tal:replace="foo/bar/my:complexscript">
...which would be roughly equivalent to
"python:here.zptlib.complexscript(foo.bar)". For now, I'm going to wait
for reactions to the current implementation.
Cheers,
Evan @ 4-am
More information about the ZPT
mailing list