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:
parent
8bba7e4d8d
commit
2347441308
4 changed files with 22 additions and 5 deletions
|
@ -9,6 +9,16 @@
|
||||||
tal:attributes="action request/URL"
|
tal:attributes="action request/URL"
|
||||||
tal:define="container_contents view/listContentInfo">
|
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=""
|
<input type="hidden" name="type_name" value=""
|
||||||
tal:attributes="value request/type_name"
|
tal:attributes="value request/type_name"
|
||||||
tal:condition="request/type_name|nothing"
|
tal:condition="request/type_name|nothing"
|
||||||
|
|
|
@ -44,7 +44,7 @@ We are now ready to use the corresponding browser view:
|
||||||
>>> bview.items()
|
>>> bview.items()
|
||||||
[3, 4, 5, 6]
|
[3, 4, 5, 6]
|
||||||
>>> bview.last
|
>>> 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
|
The real reporting stuff
|
||||||
------------------------
|
------------------------
|
||||||
|
|
|
@ -77,7 +77,5 @@ class Batch(object):
|
||||||
def getIndexAbsolute(self, idx=0):
|
def getIndexAbsolute(self, idx=0):
|
||||||
if idx < 0:
|
if idx < 0:
|
||||||
idx = max(len(self.pages) + idx, 0)
|
idx = max(len(self.pages) + idx, 0)
|
||||||
#if idx < 0 or idx >= len(self.pages):
|
|
||||||
# return None
|
|
||||||
return idx
|
return idx
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ HTML providing template.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import urllib
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from cybertools.reporter.batch import Batch
|
from cybertools.reporter.batch import Batch
|
||||||
|
|
||||||
|
@ -69,8 +70,16 @@ class BatchView(object):
|
||||||
|
|
||||||
def urlParams(self, page):
|
def urlParams(self, page):
|
||||||
batch = self.batch
|
batch = self.batch
|
||||||
return ('?b_page=%i&b_size=%i&b_overlap=%i&b_orphan=%i'
|
params = {'b_page': page + 1, 'b_size': batch.size,
|
||||||
% (page+1, batch.size, batch.overlap, batch.orphan) )
|
'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):
|
def url(self, page):
|
||||||
return str(self.request.URL) + self.urlParams(page)
|
return str(self.request.URL) + self.urlParams(page)
|
||||||
|
|
Loading…
Add table
Reference in a new issue