[Zope] ZPT nebie questions

Charlie Reiman creiman@kefta.com
Tue, 14 Jan 2003 11:39:22 -0800


I'm in the middle of trying to reimplement some DTML stuff in ZPT and I'm
hitting what must be newbie problems.

1) Iteration and python expressions.

I've got something like this:

    <table class="info" width="100%"
    tal:repeat="origin python:here.getorigins(
      fd=request.other['from_date'],
      td=request.other['to_date'])">

I then want to nest another repeat statement, based on origin:

<tr class="somerow"
 tal:repeat="row python:here.innerstuff(
 request.other['from_date'],
 request.other['to_date'],
 origin)">    <!-- this line is borked -->

Using 'origin' here fails, as does 'repeat.origin' or 'repeat.origin.origin'
(the actual attribute I'm trying to get to) or 'repeat['origin'].origin'.
What is the chant I need to access repeat variables from python expressions?

2) Whither 'fmt='?

I know this was answered but my search hasn't turned up any answer. I used
to do this:

<td class="num"><dtml-var hits fmt="%d"></td>
<td class="num"><dtml-var ratio fmt="%.1f">%</td>

This works in ZPT:

<td class="num"
  tal:content="python:'%d' % int(row.hits)">0.0</td>
<td class="num"
  tal:content="python:('%.1f' % float(row.ratio))+'%'">0.0%</td>

But it seems like there should be an easier way.