[Zope] Re: SortEx module feature request thinking
Oleg Broytmann
Oleg Broytmann <phd@phd.pp.ru>
Tue, 28 Aug 2001 18:39:59 +0400 (MSD)
Hello!
I hope you know the Sort and SortEx are now in Zope 2.4? Just under
different names :)
Well, about your question: instead of predefined 'nocase' you can pass
your own function (see examples in SortEx tar.gz). And in this function you
can do whatever you want - you can determine types of your parameters,
compare them in any way you prefer, etc. SorEx is a framework you can use
to simplify your sorting needs!
On Tue, 28 Aug 2001, Peter Bengtsson wrote:
> If you pass an argument to sort on to the SortEx and pass also 'nocase' it
> breaks if the thing to sort on cannot be case insensitive.
>
> This works:
>
> r=SortEx(sequence, ( ( 'companyName' , ) , ) )
> # and this
> r=SortEx(sequence, ( ( 'companyName' , 'nocase' ) , ) )
> # and this
> r=SortEx(sequence, ( ( 'modificationTime' , ) , ) )
> # But this breaks! of course
> r=SortEx(sequence, ( ( 'modificationTime' , 'nocase' ) , ) )
>
> Sensible.
>
> But suppose that one really doesn't know what one is sorting one?
> * If its a string property, I want it case-insensitive.
> * If its a date property, don't pass the 'nocase' thing
>
> Maybe there is a way to do this, but I don't know how. So how?
> If there isn't a way to do this, can I suggest a syntax like this:
>
> r=SortEx(sequence, ( ( REQUEST.foobar , 'nocase' , 'anyproperty' ) , ) )
> ...or...
> r=SortEx(sequence, ( ( REQUEST.foobar , 'nocase_nocomplain' ) , ) )
Oleg.
----
Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.