improvements/fixes for batching

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1244 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-06-10 06:45:40 +00:00
parent 8bba7e4d8d
commit 2347441308
4 changed files with 22 additions and 5 deletions

View file

@ -9,6 +9,16 @@
tal:attributes="action request/URL"
tal:define="container_contents view/listContentInfo">
<metal:keep-batch define-macro="keep_batch_params">
<tal:param repeat="param python:('b_page', 'b_size', 'b_overlap', 'b_orphan')">
<input type="hidden"
tal:define="value request/?param|nothing"
tal:condition="value"
tal:attributes="name param;
value value" />
</tal:param>
</metal:keep-batch>
<input type="hidden" name="type_name" value=""
tal:attributes="value request/type_name"
tal:condition="request/type_name|nothing"

View file

@ -44,7 +44,7 @@ We are now ready to use the corresponding browser view:
>>> bview.items()
[3, 4, 5, 6]
>>> bview.last
{'url': 'http://127.0.0.1?b_page=5&b_size=4&b_overlap=1&b_orphan=0', 'title': 5}
{'url': 'http://127.0.0.1?b_size=4&b_overlap=1&b_page=5&b_orphan=0', 'title': 5}
The real reporting stuff
------------------------

View file

@ -77,7 +77,5 @@ class Batch(object):
def getIndexAbsolute(self, idx=0):
if idx < 0:
idx = max(len(self.pages) + idx, 0)
#if idx < 0 or idx >= len(self.pages):
# return None
return idx

View file

@ -23,6 +23,7 @@ HTML providing template.
$Id$
"""
import urllib
from zope.cachedescriptors.property import Lazy
from cybertools.reporter.batch import Batch
@ -69,8 +70,16 @@ class BatchView(object):
def urlParams(self, page):
batch = self.batch
return ('?b_page=%i&b_size=%i&b_overlap=%i&b_orphan=%i'
% (page+1, batch.size, batch.overlap, batch.orphan) )
params = {'b_page': page + 1, 'b_size': batch.size,
'b_overlap': batch.overlap, 'b_orphan': batch.orphan}
form = self.request.form
for p in form:
if p not in params:
break # we get UnicodeEncode errors here :-(
v = form.get(p)
if v:
params[p] = v
return '?' + urllib.urlencode(params)
def url(self, page):
return str(self.request.URL) + self.urlParams(page)