Paul Winkler wrote:
On Wed, Jul 23, 2003 at 02:04:51PM -0400, Fred L. Drake, Jr. wrote:

There are those that consider using python: expressions in ZPT should
be discouraged, primarily because it's yet another syntax for a web
developer to learn.

I'm not necessarily one of them, but I am sympathetic with that

That's not my reasoning either. :-)

My feeling is that you should avoid mixing syntaxes in a single document. The more syntaxes you mix, the more perfection you require of developers. Take the following code:

<pre tal:content="python: text.replace('\\n', '<br /')" />

This code has at least four errors (one XML, one HTML, one ZPT, one Python--can you spot them?), but it will work anyway without complaint. This is hard to debug because it requires complete understanding and perfect spelling of four languages at once: XML, ZPT, HTML, and Python.

I wholeheartedly agree that newcomers should learn Python as well as ZPT, but there should be a clean separation of the two.

My concern is that ZPT will grow so many conveniences that it will become easier to abuse it in the same way that DTML has been widely abused. New zope developers will then be more tempted to
avoid python ("i don't have time to learn another language") and
with the best intentions will do themselves a serious disservice: a lot of things will still be unnecessarily difficult compared to using python, and a lot of logic will be in templates where it doesn't belong.

I have a slightly different concern. You're concerned that people will use path expressions when they could use Python expressions. I'm concerned that people will use *any* kind of complicated expressions instead of Python code blocks. To me, the choice between path expression and Python expression isn't very meaningful; either way I'm putting logic in a template, and if it's too complicated, it doesn't belong there. The better goal is to move complicated logic out of templates and into Python code blocks, don't you think?

I know of two ways to avoid writing complicated expressions in templates:

1. Move complicated expressions into Python code blocks.

2. Provide a simpler equivalent for complicated expressions.

Prefixes in the middle of path expressions attacks #2.


Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - )

Reply via email to