From 2347441308b18ec557d81dc60947a9e2c3aadb14 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 10 Jun 2006 06:45:40 +0000 Subject: [PATCH] improvements/fixes for batching git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1244 fd906abe-77d9-0310-91a1-e0d9ade77398 --- container/contents.pt | 10 ++++++++++ reporter/README.txt | 2 +- reporter/batch.py | 2 -- reporter/browser/batch.py | 13 +++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/container/contents.pt b/container/contents.pt index f3aab5e..89c0890 100644 --- a/container/contents.pt +++ b/container/contents.pt @@ -9,6 +9,16 @@ tal:attributes="action request/URL" tal:define="container_contents view/listContentInfo"> + + + + + + >> 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 ------------------------ diff --git a/reporter/batch.py b/reporter/batch.py index 4fd7093..cdecbcb 100644 --- a/reporter/batch.py +++ b/reporter/batch.py @@ -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 diff --git a/reporter/browser/batch.py b/reporter/browser/batch.py index 1bdb832..d9a705a 100644 --- a/reporter/browser/batch.py +++ b/reporter/browser/batch.py @@ -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)