[ZPT] v2 of Path Prefixes in CVS

Evan Simpson evan at 4-am.com
Sun Aug 31 18:12:39 EDT 2003


Fergal Daly wrote:
> First impression is it seems like an odd thing to have in TAL, that it would 
> be much more natural to define the prefixes in your code, rather than in the 
> template, otherwise you will have to define them in every template you use or 
> start to make include templates which contain no markup but set up your 
> commonly used prefixes. Is the scope global or local or can I say "global 
> prefix blah".

The scope is global.  Zope 3 will have facilities for defining prefixes 
in an entire site, or package, or whatever level is most appropriate. 
Zope 2 doesn't really have the machinery to do this right.

> I find the prefix expressions very confusing. When reading the one above I'm 
> thinking foo, foo/bar, foo/bar/my, no, hold on, my has a ":" after it so 
> forget about "foo/bar" for a minute, remember that my is here/zptlib, now 
> call complexscript on here/zptlib with foo/bar as an argument. With simple 
> arument passing I just mentally replace my with here/zptlib and everything 
> else is exactly as before.

That example doesn't give a good feel for typical usage.  In Zope 3, it 
will commonly be used to access Dublin Core properties, as in 
"here/myDocument/dc:title".  Among the builtins in Zope 2 we have 
'item:' for integer item access, as in "options/a_list/item:1".  This 
does not fit well into your argument-passing form.

> If you're going to do it, it would be better to use a different character to 
> separate "foo/bar" and "my", space for instance.

Spaces and parens are valid characters in Zope object names, and 
therefore in path segments. In any case, the syntax is not likely to 
change, given the existing Zope 3 implementation.

Unless you use longish prefix names, it should be quite easy to get into 
the habit of visually parsing "/pname:arg/".

Cheers,

Evan @ 4-am




More information about the ZPT mailing list