[Zope] Using custom comparasion function in sequence.sort

Dieter Maurer dieter at handshake.de
Mon Feb 14 13:09:35 EST 2005

Hong Yaun wrote at 2005-2-14 13:11 +0800:
> ...
>A closer look at make_sortfunctions shows that it tries to find the 
>custom comparasion in the name space '_', which is default to None in 
>sort(). So it seems I need only supply the correct name space as the 
>third, undocumented parameter to sequence.sort for it to find my 
>comparasion function.

Unfortunately, this is not so easy, because this argument must
behave like a DTML namespace...
Especially, it must have a "getitem" method with 2 positional arguments.

Maybe, you can bind the "namespace" in your Python script.

When called from a DTML object, this namespace is bound to
the DTML namespace, when called from a PageTemplate,
this namespace contains the variables defined at this point
of the PageTemplate.

But apparently, "sequence.sort" was not designed to be used
from something differently than DTML (which is a pity).


More information about the Zope mailing list