[Zope] Tuple unpacking in DTML

Daniel Fairs daniel.fairs@spiderplant.net
Fri, 8 Jun 2001 17:00:37 +0100


Hi,

How do you unpack a tuple in DTML?

I have a python method getEntries that returns a list of tuples. Each tuple
is of the form: (doc_text, doc_title, doc_date)

The list is generated with:
for thisDoc in documents:
	docText = thisDoc.document_src()
	newText = string.replace(docText, '\n', '<br />')
	docSequence.append((newText, thisDoc.bobobase_modification_time()))

I want to display this data using the following code:

<dtml-in getEntries reverse>
	<dtml-let expr="sEntry,sTitle,oTime=_.getitem('sequence-item')">
		<tr>
			<td><dtml-var oTime fmt=aCommon></td>
			<td><dtml-var title></td>
		<tr>
			<td valign="top" colspan="2"><dtml-var sEntry></td>
		</tr>
	</dtml-let>
</dtml-in>

However, Zope barfs whenever I try to save this, giving:

Expression (Python) Syntax error:
invalid syntax

, for tag <dtml-let expr="sEntry,sTitle,oTime=_.getitem('sequence-item')">,
on line 10 of contentPanel

What am I doing wrong? Why can't I use the tuple unpacking syntax in DTML?
Or am I going about this completely the wrong way? ;)

I would just do a normal <dtml-var document> etc. to publish the date, but I
want to replace all the newlines with <br /> tags.

Many thanks,
Dan

_________________________________________________________________
Daniel Fairs | daniel.fairs@spiderplant.net | www.spiderplant.net