[Zope] dtml-in sort by generic function

Oleg Broytmann Oleg Broytmann <phd@mail2.phd.pp.ru>
Sun, 11 Mar 2001 18:17:26 +0300 (MSK)


Hello!

   For quite some time we, the Russian users of DTML (mostly we use DTML,
not entire Zope), have a problem with dtml-in sorting. The sort is not
locale-aware.
   The problem is that DT_In.py just calls s.sort(), and this is wrong way
for locale-aware sort. For locale-aware one needs to write special
comparisonfunction . In the most simple case the call is just
s.sort(locale.strcoll).

   Well, I thought I'd write a patch for DT_In.py that would add another
flag to dtml-in, something like
   <dtml-in seq sort=surname use_locale>,
but a colleague of mine, Dennis Otkidach suggested more general approach -
to make a patch that will allow to pass a generic function to sort(),
something like
   <dtml-in seq sort=surname sort_func=foobar> where sort_func points to a
Python function (like locale.strcoll), or Python Script function, or such.

   Any opinion? I see a minor problem here - if I want just locale-aware
sort, I would write
   <dtml-in seq sort=surname sort_func=_.locale.strcoll>,
but module locale is not available in DTML.

Oleg.
----
     Oleg Broytmann     http://www.zope.org/Members/phd/     phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.