<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
beno - wrote:
<blockquote
 cite="mid20060726220418.104.qmail@web33910.mail.mud.yahoo.com"
 type="cite">
  <div>Hi;</div>
  <div>I have the following block of code:</div>
  <div>&nbsp;</div>
  <div>&lt;table tal:define="objects here/objectValues;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sort_on python:(('title', 'nocase', 'asc'),<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ('bobobase_modification_time',
'cmp', 'desc'));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sorted_objects python:sequence.sort(objects,
sort_on);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; start python:getattr(request, 'start', 0);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; batch
python:modules['ZTUtils'].Batch(sorted_objects, size=10, start=start);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; previous python:batch.previous;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; next python:batch.next"&gt;<br>
&nbsp; &lt;tr tal:repeat="item batch"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;td tal:content="item/title"&gt;title&lt;/td&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;td tal:content="item/bobobase_modification_time"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modification date&lt;/td&gt;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp; &lt;td tal:content="here/author"&gt;author&lt;/td&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;td tal:content="here/content"&gt;content&lt;/td&gt;<br>
&nbsp; &lt;/tr&gt;<br>
&lt;/table&gt;<br>
  </div>
  <div>that works fine. But I'd like to call the following in that
table:</div>
  <div>&nbsp;</div>
  <div>&lt;td&gt;&lt;tal:content
metal:use-macro="here/XXX/macros/author"&gt;&lt;/tal:content&gt;&lt;/td&gt;<br>
  </div>
  <div>where "XXX" is the "item" that changes each time a new item from
the batch is called. In other words, there is a folder with a "batch"
of files, and each file is an "item". So, since the files' titles are
simply sequential numbers, it would look something like this:</div>
  <div>&nbsp;</div>
  <div>&lt;td&gt;&lt;tal:content
metal:use-macro="here/1/macros/author"&gt;&lt;/tal:content&gt;&lt;/td&gt;<br>
&lt;td&gt;&lt;tal:content
metal:use-macro="here/2/macros/author"&gt;&lt;/tal:content&gt;&lt;/td&gt;<br>
&lt;td&gt;&lt;tal:content
metal:use-macro="here/3/macros/author"&gt;&lt;/tal:content&gt;&lt;/td&gt;<br>
...</div>
</blockquote>
How do I do that? Even better, is it possible to just open up each file
and read its contents??
<blockquote
 cite="mid20060726220418.104.qmail@web33910.mail.mud.yahoo.com"
 type="cite">
  <div>Thanks,</div>
  <div>Ben</div>
  <p> </p>
  <hr size="1"></blockquote>
<br>
Ben,<br>
First this is wrong:<br>
<br>
&lt;td&gt;&lt;tal:content ...<br>
<br>
If should be<br>
&lt;td tal:content ...<br>
<br>
But that may be wrong in the context you've given.&nbsp; <br>
<br>
Since "do it in python" has been a theme lately, you can also return a
macro from a python script like so:<br>
<br>
Where there is an author might be a parameter.<br>
#some python script<br>
#<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return container.YourMacroFolder.someMacro[ author ]<br>
-----------------------------------------------------------------------<br>
<br>
And in your ZPT: (where result.author is just a stub for whatever your
using)<br>
<br>
&lt;td&gt;&lt;span&nbsp; metal:use-macro="python:
context.youPythonScript(result.author)"&gt;macro goes
here&lt;/span&gt;&lt;/td&gt;<br>
<br>
I suggest *always* doing stuff in python when things are not clear.&nbsp;
Then code back into your Page Templates, if desired<br>
<br>
DAvid<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>