[Zope-dev] Re: TALES idea: tuple unpacking
Philipp von Weitershausen
philipp@weitershausen.de
Wed, 23 Jul 2003 08:21:02 -0500
Richard Jones wrote:
> During the Melbourne Zope3 Sprint, someone ran up against a situation where
> they'd have liked to have TALES perform a tuple unpacking like Python can.
> I've just run into a similar situation :)
>
> Say a method listFilesByUser returns a list of (user, [files]) it'd be nice to
> be able to::
>
> tal:repeat="user,files here/listFilesByUser"
>
> or similar. Currently we would have to use a python: expression to manually
> unpack the tuple. Kinda yucky.
I agree that it is 'yucky', but I have to disagree with your proposed
solution. I would rather suggest making TALES aware of integer indexes
for sequences. Example::
<tal:block repeat="user_files here/listFilesByUser">
User: <tal:dummy replace="user_files/0" />
File: <tal:dummy replace="user_files/1" />
</tal:block>
Regards,
Phil