[ZPT] Re: batching and sorting in one go

Casey Duncan casey@zope.com
27 Jun 2002 15:42:31 -0400


On Thu, 2002-06-27 at 15:25, Michal Kurowski wrote:
> Casey Duncan [casey@zope.com] wrote:
> > The problem is that the batch object has no sort method. So it throws
> > that attribute error when you call: out = batch.sort(...)
> > 
> > You need to sort the results before you batch it. Since you are using a
> > ZSQL method, it probably makes sense to add a variable "ORDER BY" clause
> > to it, passing the name of the column to sort on as an argument to the
> > ZSQL method.
> > 
> > Then the database will do the sorting for you which is usually
> > desireable.
> > 
> > hth,
> > 
> > -Casey
> 
> 
> OK, your right but I'm still having problems...
> 
> How would I test presence of "sorted" and non-sorted sql results in a
> template ? 
> 
> I've got that:
> 
> <a tal:attributes="href python: here.pass_sorted(variable='status', mode='asc')">
> 
> where pass_sorted is anothr ZSQL method that takes additional
> parameters.
> 
> Is there a simple way to re-render my template after testing "results" ?
> 
> --
> Michal Kurowski
> <michal@genesilico.pl>

You know because the column to sort on is passed in the request. You
pass this along to the sql method and use it to display the user
interface correctly.

Re-rendering the template is a matter of creating a link to itself that
passes the desired sorting parameters.

-Casey