[ZPT] Batching goes where?

Jim Fulton jim@digicool.com
Thu, 12 Apr 2001 16:18:49 -0400


Evan Simpson wrote:
> 
> 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.

I don't think this belongs in the DocumentTemplate package. It's 
useful for alot of things. Heck, people might want to use it with
htmlgen or psp. ;)

I suggest adding a stand-alone zBatch package (like TAL). I'd be in favor
of adding it to the Zope core at some point.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org