[ZPT] batching and sorting in one go
Michal Kurowski
michal@genesilico.pl
Thu, 27 Jun 2002 20:12:45 +0200
Hi,
I'm rather a newcomer to Zope and I'm afraid I try to do something I'm
not quite up to.
There's a lot of nice guides on sorting and batching but I'm still I'm
having a lot of trouble to put the pieces together.
What I've got:
A rather simple ZSQL method which is supposed to be displayed in the
table. There are links on that page to sort results based on some
criteria and there're batching links.
I decided to do this like this: Do everything in a Py script which has
parameters both from the ZSQl method and from those sorting links.
My script is a stolen one from the zopelabs example by cduncan.
I try to modify it to accept additional parameters to enable sorting
like this:
<td width="15%" align="right"><a tal:attributes="href python:
here.adv_sort(results,arg='born',mode='up')" href="up"><span
tal:replace="structure root/meta/images/up">up</span></a></td>
<td width="15%" align="right"><a tal:attributes="href python:
here.adv_sort(results,arg=born,mode='down')" href="down"><span
tal:replace="structure root/meta/images/down">down</span></a></td>
etc.
and in the script:
batch = Batch(results, size, start, 0, orphan, overlap)
if arg is not None and mode is not None:
if mode == 'up':
out = batch.sort(arg, 'asc')
elif mode == 'down':
out = batch.sort(arg, 'desc')
else:
out = batch
Something is wrong in here - I've errors like
Error Type: TALESError
Error Value: exceptions.AttributeError on sort in "", at line 46, column 34
Could you please explain it me ?
--
Michal Kurowski
<michal@genesilico.pl>