[Zope-dev] TALES idea: tuple unpacking
Fred L. Drake, Jr.
fred@zope.com
Wed, 23 Jul 2003 11:44:59 -0400
Paul Winkler writes:
> In this case, consider a trivial change to (or wrapper around)
> listFilesByUser to make it return a sequence of dictionaries
> like {'user': some_user, 'files': (file1, file2...)}
This is exactly what the proposal I posted a couple of weeks ago was
trying to avoid. While adding another layer of indirection around the
actual call to listFilesByUser() isn't all that costly, these things
add up, especially since so many temporary objects are getting created
and thrown away.
I know for Zope 3, we'd like to get away from having to write a view
class simply to hook up helpers like this when something simpler would
do.
So far, two distinct approaches have been presented, with minor
variations for each. I won't go into the variations, but the two
approaches are:
- Use a Python-like sequence unpacking syntax. This is probably most
comfortable to template authors who are Python programmers first,
and web guys (or gals!) second.
- Use the namespace qualifiers to get an adapter to handle converting
container lookup to a sequence indexing operation. This plays off
the machinery being built anyway, so is quite attractive, and
doesn't affect the basic syntax or implementation of TAL, but only
of the TALES expression engine. This is very attractive because it
pushes the support for this feature somewhere the application
controls in as much detail as it wants.
-Fred
--
Fred L. Drake, Jr. <fred at zope.com>
PythonLabs at Zope Corporation