[Zope-dev] Re: TALES idea: tuple unpacking

Evan Simpson evan@4-am.com
Tue, 29 Jul 2003 17:04:46 -0500


Jim Penny wrote:
> But, what does all of this have to do with index:, key:, int:, etc.?
> index: and key: are particularly interesting, in that they use
> different syntax for something that python conflates syntactically. 
> That is, an integer indexed reference looks exactly like a string
> indexed reference, both have form structure[key].

I proposed distinct key: and item: in order to kill some implicit magic 
before it was born:

"x/key:0" is the same as "python:x['0']", while "x/item:0" is the same 
as "python:x[0]".

It seems clear to me that subpath prefixes are going to be part of Zope 
3, no matter how opinion on this thread goes.  It wasn't hard to 
implement them for Zope 2, and I find them useful.  While I agree that 
someone who can deal well with "x/item:0" will have no problem with 
"python:x[0]", I also assert that many such people would join me in 
prefering "options/lib/data/my.sql/call:/item:0/state" to 
"options['lib'].data['my.sql']()[0].state" if only because the former 
allows me to specify access methods *only* for the exceptions to the 
norm, not for every path step.  If that isn't valuable, what about path 
expressions is?

I also offer for general consideration the following:

options/foo/item:0 | request/foo/item:0 | default
data/stat/fmt:thousands_commas | string:No data.

Python expression equivalents, please?

Cheers,

Evan @ 4-am