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

Paul Winkler pw_lists@slinkp.com
Wed, 23 Jul 2003 12:10:09 -0400


On Wed, Jul 23, 2003 at 10:48:10AM -0400, Shane Hathaway wrote:
> Think of prefixes as site-wide, generally useful Python scripts.

That's fine and dandy... but please please PLEASE don't let that
be the only way to call them. Put them in ZTUtils, or
Products.PythonScripts.standard, or someplace generally available.

What bothers me is the tendency in z2 to improve one tool with 
little features that would be "nice to have", adding functionality 
that is either not provided elsewhere, or is provided elsewhere in a 
totally different way. So please, if there's new functionality
you want to add, consider: how would I use this
functionality from a script? from dtml? from a product?

> Quite 
> often some API returns something that's intuitively easy to present, but 
> ZPT's syntax makes it somewhat difficult to present.  For example, it 
> should not be necessary to write a Python script or expression every 
> time you want to format the number 5 as "$5.00".

No script needed, and I *like* that zpt encourages python
expressions. Makes it easy to refactor things out into Scripts when 
you realize that your page template is doing too much work.

In this case, the expression you need is documented
(although it really needs an explicit example) in the Zope Book,
API Reference:

<span tal:define="pss modules/Products/PythonScripts/standard">
  <div tal:content="python:pss.dollars_and_cents(5.0)">
       $1.00
  </div>
</span>

You could argue against the define at the beginning, but I think of
those as being analogous to python import statements:
"before I get started, I'm going to give myself convenient access
to the stuff I need."

You could also argue that we need a non-US-centric currency formatter,
and I agree; but I say again that we need it everywhere and not only via
some special syntax in ZPT.

-- 

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