[Zope] sequence.sort from python

Andrew Altepeter aaltepet at bethel.edu
Thu Oct 2 15:30:24 EDT 2003


Hi All!

I am trying to use the sequence.sort function to sort the results from
an ldap search (using the LDAPDelegate module from LDAPUserFolder to
search ldap).  This is in a custom python product, not in the zodb.

Since every attribute value returned is a tuple, I can't exactly use
sort's standard cmp function (at least it doesn't seem to work for me).
I thought I'd try to use a custom comparison function, so I wrote my own
to compare the first item in each attribute's tuple.  I then called
sort:

sequence.sort(ldap_results,(('givenName',res_cmp),))
(res_cmp is the custom function)

I get an attribute error saying 'None' object has no attribute
'res_cmp'.

The traceback (included below) says that the error occurred on line 178
of SortEx.py.  This line tried to get the actual function using the
current namespace as passed into the sort function.  I didn't pass one
in, and the default is None.

Is there anyway around this?  Is there a way to create my own namespace
and pass it in?  Would it be easiest to delegate the sort to a zodb
script?

Thanks for the help,
Andy






More information about the Zope mailing list