-----Original Message----- From: Adam Karpierz [mailto:karpierz@alpha.pl] Sent: Thursday, January 18, 2001 02:08 To: Loren Stafford Subject: Re: Variable sort and multiple sort in dtml-in ----- Original Message ----- From: "Loren Stafford" <lstafford@morphics.com> To: <adares@alpha.pl>; <karpierz@alpha.pl>; <karpierz@itl.pl> Cc: <zope@zope.org> Sent: Thursday, January 18, 2001 4:16 AM Subject: Variable sort and multiple sort in dtml-in
On 02 July 2000, Adam Karpierz, posted a patch that would allow an expression for the sort specification for the dtml-in tag. Did that patch, or something like it, ever find its way into the Zope core?
I also seem to remember some discussion of sorting on multiple items (but can't find any trace of it in the archives). For example, in an employee directory, sort on employee name within department. Anyone know how?
Hi Loren (sorry for my "approximate english":) There is a good news in this matter. I'v noticed that in Zope 2.3.0b1 was included stricte similar way as my patch. Only names of variables was changed: My name of variable was sort-python, now exists sort_expr Additionally DC guys added reverse_expr variable. Here is a example of use (from my patch but translated to use sort_expr) <dtml-call "REQUEST.set('sortstrvar', _.string.lower('tItLe')+','+'id')"> <html> <pre> 1."Hardcoded" =========== <dtml-in "objectItems(['Image'])" sort=title,id> <dtml-var id>....<dtml-var title> </dtml-in> 2.Indirectly ============ <dtml-in "objectItems(['Image'])" sort_expr="'title,id'"> <dtml-var id>....<dtml-var title> </dtml-in> 3.Indirectly ============ <dtml-in "objectItems(['Image'])" sort_expr="sortstrvar"> <dtml-var id>....<dtml-var title> </dtml-in> 4.Indirectly ============ <dtml-in "objectItems(['Image'])" sort_expr="_.string.lower('tItLe')+','+'id'"> <dtml-var id>....<dtml-var title> </dtml-in> </pre> </html>
I'm trying to provide user-specified sorting on the records I pull from a SQL database. When the user specifies sorting on Department, I assume he wants the records order by Name within each department, but I can't see how to do that with ZSQL or dtml-in.
User would specify multiple keys sort (dr Lazarus patch which is included to core from Zope 2.2.2 (?)) eg: <dtml-call "REQUEST.set('usersort', 'department,name')"> <html> <pre> <dtml-in recordset sort_expr="usersort"> <dtml-var department> <dtml-var name> </dtml-in> </pre> </html> But best news for you is that sort_expr patch may be very simply implemented for Zope 2.2.4 and 2.2.5 Simply copy the file: <Zope230b1>/lib/python/DocumentTemplate/DT_In.py to <Zope224|5>/lib/python/DocumentTemplate/DT_In.py thats all you need :) It is possible because nothing else except sort_expr patch was changed in this file, without dependences and influences for other pieces of Zope Best Regards Adam -- Adam Karpierz karpierz@alpha.pl