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

Paul Winkler pw_lists@slinkp.com
Tue, 29 Jul 2003 14:27:34 -0400


On Tue, Jul 29, 2003 at 06:22:38PM +0100, Chris Withers wrote:
> Paul Winkler wrote:
> 
> >On Wed, Jul 23, 2003 at 11:07:20AM -0500, Evan Simpson wrote:
> >
> >>...  This would allow 
> >>"options/a_mapping/key:items/index:0" rather than 
> >>"python:options['a_mapping']['items'][0]".
> >
> >Why is that an improvement? 
> 
> Personally, I find it much easier to read...

I find the opposite:

Assuming that the reader understands python, s/he has to
perform the mental translation anyway in order to understand
how this expression uses the objects it refers to.

Assuming that the reader does NOT understand any python, 
it doesn't make much sense. The immediate questions arise: "What's a 
key?" "What's an index?" "What's the difference between them?" 
"How do I know when to use one or the other?"
And, how do you answer those questions without talking about
python data structures?

> I wonder what non-python'ers would think?

well, that's a very good and relevant question, but I doubt
we will find them on this mailing list :-)
I would really like to know.

> >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?
> 
> For me, that would be ideal...
> 
> >I really think that's a mistake.
> 
> What leads you to believe that?

The appeal of TALES path expressions lies in their simplicity.
I don't want them to feature-creep into a general purpose 
programming language. The more complex these expressions get, the more 
work a zope developer (e.g. someone developing new content types, 
services, etc.) has to expend on mentally translating between different 
languages, which is always an opportunity to get something wrong
as we've already discussed.  We all know that Python has a near-unbeatable
record as an easy-to-use, well-designed, and downright fun language.
It has a great reputation as a "first language".  These new proposals for 
TALES path expressions do not have any such track record, so I am
naturally skeptical that they are going to beat python at one of its
strengths: readability and novice-friendliness.

Consider what happened with Zope 2 and DTML: the templating
language had enough features that novice developers often got themselves
into trouble by writing excessively complex templates with embedded
logic. The zope 2 tutorial and most other available documents gave the
impression that you didn't need to learn python to get things done
in Zope. Since the addition of ZPT and Python Scripts, things have
improved enormously; but I remember a time when the zope@zope.org list 
was full of questions like "how do I do my complex task in DTML". 
It was easy to get your feet wet, and without clear & explicit ways
to use python, it was easy to fall off the continental shelf where 
suddenly nothing worked anymore and nothing made sense.  

So I am very wary of ZPT becoming "Son of DTML From Hell",
and that's what the proposed extensions smell like to me.

To frame it as a practical question: how is the template author going to 
get something non-trivial done? 

Assuming that TALES python expressions are banned/discouraged/whatever, 
there are 3 choices:

1) The template author writes some auxiliary python code 
(whether this is a script or a Product or a Persistent Module or 
whatever). This is the case most familiar to me - I'm usually doing 
most of my work alone.  In this case the author has to know both 
ZPT and python - but not both in the same document. 

2) Stretch the capabilities of the template language so that no
python is necessary anywhere.
I think we agree that *currently* this is bad practice, when it's
even possible.

3) Get somebody else to write the python code, and just
refer to the code objects with TALES path expressions.

This is what I think you are suggesting - yes? no?
It's hard for me to imagine working strictly in this fashion, because 
in my limited experience I've never worked that way and I don't know 
anybody who does.  *Do* people actually work this way?  If you don't 
know any python, isn't it tempting to write some icky template code 
yourself instead of waiting for the code guy to have time to help you?

-- 

Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's USELESS MEGA BOY!
(random hero from isometric.spaceninja.com)