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

Jim Penny jpenny@universal-fasteners.com
Tue, 29 Jul 2003 17:31:55 -0400


On Tue, 29 Jul 2003 16:43:21 -0400
Shane Hathaway <shane@zope.com> wrote:

> [Paul Winkler]
> >>>I guess I don't understand the goal. Are we trying to make it
> >>>so that zpt authors don't have to know any python?
> 
> [Chris Withers]
> >>For me, that would be ideal...
> 
> [Paul Winkler]
> >>>I really think that's a mistake.
> 
> Guys, that line of thinking is a distraction.  ZPT authors ought to 
> learn Python.  The issue is deeper than that.  I'll explain below.
> 
> [Paul Winkler]
> > Assuming that TALES python expressions are
> > banned/discouraged/whatever, [...]
> 
> Python expressions won't be banned.  I will never consider them 
> discouraged for all cases, either.  There will always be a need for 
> constructs like:
> 
> <div tal:condition="python: a == b">...</div>
> <div tal:condition="python: (a and b) or c">...</div>
> 
> However, the following is quite bad:
> 
> <tal:x define="ss nocall:modules/Products/PythonScripts/standard">
>   <a tal:attributes="href python: ss.url_quote(some_url)" />
> </tal:x>

Frankly, would not even have occurred to me - I would probably create a
tiny Script (Python) en passant, and called it directly, as:
<a tal:attributes="href python: here.url_quote(some_url)" />.  I did not
realize that this is deprecated in Zope3.

> 
> This is un-Pythonic in numerous ways.

snip

> <a tal:attributes="href here/format:url_quote" />
> 
> To me, that's a vast improvment, and it's only one example.
> 
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].

Jim Penny