[ZCM] [ZC] 812/ 2 Comment "dtml-in batch weirdness"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin@zope.org
Sat, 22 Feb 2003 10:37:30 -0500


Issue #812 Update (Comment) "dtml-in batch weirdness"
 Status Pending, Zope/bug critical
To followup, visit:
  http://collector.zope.org/Zope/812

==============================================================
= Comment - Entry #2 by mjablonski on Feb 22, 2003 10:37 am

I don't see any bug... and I don't see any CRITICAL bug. Please use critical for really critical issues... Propose: Reject this issue

You have to use the "batch_start"-indexes with the right offsets in <dtml-in>. Here's a corrected version of your script which works as expected:

<dtml-let
  batch="_.range(100, 180)"
  batch_size="10"
  batch_start="REQUEST.get('batch_start',1)">
  
<dtml-in batch start="batch_start" size="batch_size" overlap="0">
  &dtml-sequence-item;<br>
</dtml-in>

<dtml-in batch start="batch_start" size="batch_size" previous overlap="0"> 
 <dtml-in previous-batches mapping>
  <a href="<dtml-var URL><dtml-var
  sequence-query>batch_start=<dtml-var "_['batch-start-index']+1">">
    &dtml-batch-start-index;-&dtml-batch-end-index;
  </a>
 </dtml-in>
</dtml-in>

<STRONG><dtml-var "_.int(batch_start)-1"> - <dtml-var "batch_size +
_.int(batch_start) - 2"></STRONG>

<dtml-in batch start="batch_start" size="batch_size" next overlap="0">
 <dtml-in next-batches mapping>
  <a href="<dtml-var URL><dtml-var
  sequence-query>batch_start=<dtml-var "_['batch-start-index']+1">">
    &dtml-batch-start-index;-&dtml-batch-end-index;
  </a>
 </dtml-in>
</dtml-in>

</dtml-let>

________________________________________
= Request - Entry #1 by bjorn on Feb 17, 2003 10:39 pm

I'm trying to implement a Google-like pagination using the dtml-in "batching system", and I'm getting some very strange results.  Either I'm overlooking something obvious or there is a problem with dtml-in.  See attached source code of simplified example that produces the strange results.

The first time I access the page the results are as follows:

    0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 

If I click '10-19' it'll take me to batch_start=10, which gives the following strange results:

    0-8 10-19 19-28 29-38 39-48 49-58 59-68 69-78 79-79 

I have no idea why the first batch is now 0-8 and the next batch is now 19-28.  Shouldn't they be 0-9 and 20-29 like above?


-----------------------------

<dtml-let
  batch="_.range(100, 180)"
  batch_size="10"
  batch_start="REQUEST.get('batch_start', 0)">

<dtml-in batch start="batch_start" size="batch_size" overlap="0">
  &dtml-sequence-item;<br>
</dtml-in>

<dtml-in batch start="batch_start" size="batch_size" previous overlap="0"> <dtml-in previous-batches mapping>
  <a href="<dtml-var URL><dtml-var sequence-query>batch_start=&dtml-batch-start-index;">
    &dtml-batch-start-index;-&dtml-batch-end-index;
  </a>
</dtml-in>
</dtml-in>

<STRONG>&dtml-batch_start;-<dtml-var "batch_size + _.int(batch_start) - 1"></STRONG>

<dtml-in batch start="batch_start" size="batch_size" next overlap="0"> <dtml-in next-batches mapping>
  <a href="<dtml-var URL><dtml-var sequence-query>batch_start=&dtml-batch-start-index;">
    &dtml-batch-start-index;-&dtml-batch-end-index;
  </a>
</dtml-in>
</dtml-in>

</dtml-let>
==============================================================