Hi, I'm a developer who is trying to use the HTMLTemplate module. It's kinda easy to use, but I've encountered a little "problem". Here it is explained. I have to render a list of bug reports (to be shown on [1]), which is in the form of: [("package1", bug1), ("package1", bug2), ("package2", bug3), ...] I've got some problems with "innested repeats". Here's my template structure: -------------------------------------------------------------------------------- tem: con:package con:count rep:packagelist con:name rep:numbers con:id -------------------------------------------------------------------------------- This should render something like (the relevant bit): package1 bug1 bug2 package2 bug3 ... My problem is that it seems like a repeat() inside a for .. in ..: loop is not supported. Here's the relevant code: ---8<--- bugs = [("a", 1), ("b", 2), ("b", 3)] def renderTemplate(node, package, bugs): node.package.content = package node.count.content = `len(bugs)` bugs.sort() node.packagelist.repeat(renderBugs, [bugs]) def renderBugs(node, bugs): ids = {} for tuple in bugs: name, id = tuple if name not in ids: ids[name] = [] ids[name].append(id) # ids.items() = [('a', [1]), ('b', [2, 3])], # which seems suitable for HTMLTemplate's repeat() for tuple in ids.items(): name, bugs = tuple node.name.content = name node.numbers.repeat(renderBugNumbers, bugs) def renderBugNumbers(node, number): node.id.content = `number` ---8<--- But I don't get the expected result. Here's what I get (relevant bits): ---8<--- <div class="pageBody"> <h1><?=_("Bugs for all packages")?></h1> <table class="bugs"> <tr> <td class="name">b</td> <td class="value"> </td> </tr> <tr> <td colspan="2" class="value">2</td> </tr> <tr> <td colspan="2" class="value">3</td> </tr> </table> </div> ---8<--- Seems like it gets only the last tuple I pass to it. Is there any way to accomplish what I want? :) Kind regards, David Paleino Debian-Med Team http://debian-med.alioth.debian.org/ [1] http://debian-med.alioth.debian.org/bugs.php -- . ''`. Debian maintainer | http://snipurl.com/qa_page/ : :' : Linuxer #334216 | http://www.hanskalabs.net/ `. `'` GPG: 1392B174 | http://www.debianizzati.org/ `- 2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
Attachment:
signature.asc
Description: PGP signature