Log message for revision 68491: - Collector #2116: sequence.sort() did not work properly locale related comparison methods
Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/DocumentTemplate/sequence/SortEx.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt =================================================================== --- Zope/branches/2.9/doc/CHANGES.txt 2006-06-05 09:46:04 UTC (rev 68490) +++ Zope/branches/2.9/doc/CHANGES.txt 2006-06-05 09:55:51 UTC (rev 68491) @@ -20,6 +20,9 @@ - Updated Five to bugfix release 1.3.6. + - Collector #2116: sequence.sort() did not work properly + locale related comparison methods + Zope 2.9.3 (2006/05/13) Bugs fixed Modified: Zope/branches/2.9/lib/python/DocumentTemplate/sequence/SortEx.py =================================================================== --- Zope/branches/2.9/lib/python/DocumentTemplate/sequence/SortEx.py 2006-06-05 09:46:04 UTC (rev 68490) +++ Zope/branches/2.9/lib/python/DocumentTemplate/sequence/SortEx.py 2006-06-05 09:55:51 UTC (rev 68491) @@ -17,8 +17,9 @@ $Id$ """ -from types import TupleType +from App.config import getConfiguration + def sort(sequence, sort=(), _=None, mapping=0): """ - sequence is a sequence of objects to be sorted @@ -82,7 +83,7 @@ s=[] for client in sequence: k = None - if type(client)==TupleType and len(client)==2: + if isinstance(client, tuple) and len(client)==2: if isort: k=client[0] v=client[1] else: @@ -133,14 +134,27 @@ def nocase(str1, str2): return cmp(str1.lower(), str2.lower()) -import sys -if sys.modules.has_key("locale"): # only if locale is already imported - from locale import strcoll +def getStrcoll(): - def strcoll_nocase(str1, str2): - return strcoll(str1.lower(), str2.lower()) + if getConfiguration().locale: + from locale import strcoll + return strcoll + else: + raise RuntimeError("strcoll() is only available for a proper 'locale' configuration in zope.conf") +def getStrcoll_nocase(): + if getConfiguration().locale: + from locale import strcoll + return strcoll + def strcoll_nocase(str1, str2): + return strcoll(str1.lower(), str2.lower()) + return strcoll_nocase + + else: + raise RuntimeError("strcoll() is only available for a proper 'locale' configuration in zope.conf") + + def make_sortfunctions(sortfields, _): """Accepts a list of sort fields; splits every field, finds comparison function. Returns a list of 3-tuples (field, cmp_function, asc_multplier)""" @@ -168,9 +182,9 @@ elif f_name == "nocase": func = nocase elif f_name in ("locale", "strcoll"): - func = strcoll + func = getStrcoll() elif f_name in ("locale_nocase", "strcoll_nocase"): - func = strcoll_nocase + func = getStrcoll_nocase() else: # no - look it up in the namespace func = _.getitem(f_name, 0) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins