[ZPT] Batching goes where?

Evan Simpson evan@digicool.com
Thu, 12 Apr 2001 16:12:53 -0400


I have a nice little batch module working, based on the one Jim used for his
unit tests, but now I'm not sure where to put it.  I think it would be
useful for DTML code as well as Page Templates, and I suspect that it should
properly be DocumentTemplate/DT_Batch.py, with the Batch class exposed
directly by DocumentTemplate.  Example:

<div tal:define="Batch modules/DocumentTemplate/Batch;
     batch python:Batch(range(102), 10, start=request.form.get('start',0));
     query string:${request/URL}?start=">
<p>
 <a href="prev" tal:condition="batch/previous" tal:attributes="href
string:$query${batch/previous/start}">Previous</a>
 <a href="next" tal:condition="batch/next" tal:attributes="href
string:$query${batch/next/start}">Next</a>
</p>
<p><span tal:repeat="item batch" tal:replace="item">Item</span></p>
</div>

One problem I have, though, is that ZPT isn't yet in the core.  I don't want
people to have to copy a file from Products/PageTemplates into
DocumentTemplate, but I don't just want to drop the module into
PageTemplates and forget about it.  I could monkey-patch the Batch class
into place if it isn't there already, I suppose.

Cheers,

Evan @ digicool