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.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Charlie Reiman Sent: Tuesday, January 14, 2003 11:39 AM To: zope@zope.org Subject: [Zope] ZPT nebie questions
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.
Forget #1. I just figured it out. I had a table closing early. Doesn't that always happen right after you post? But I'd still like some hints on #2.
Charlie Reiman wrote at 2003-1-14 11:39 -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, This should not fail.
What happens precisely? Exception (Type, Value + Traceback!), wrong result?
...
2) Whither 'fmt='? There are three types of "fmt":
1. "C"-type format strings: use a python expression with the "%" operator 2. single parameter methods: use "obj/method" 3. special formatters: you find them in "Products.PythonScripts.standard" Dieter
participants (2)
-
Charlie Reiman -
Dieter Maurer