Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
09f5e800
Commit
09f5e800
authored
Jun 05, 2006
by
Andreas Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Collector #2116: sequence.sort() did not work properly
locale related comparison methods
parent
6ea19977
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
11 deletions
+33
-11
doc/CHANGES.txt
doc/CHANGES.txt
+8
-0
lib/python/DocumentTemplate/sequence/SortEx.py
lib/python/DocumentTemplate/sequence/SortEx.py
+25
-11
No files found.
doc/CHANGES.txt
View file @
09f5e800
...
...
@@ -14,6 +14,14 @@ Zope Changes
to the rules for such a type laid out in the Python docs:
http://docs.python.org/api/supporting-cycle-detection.html
after Zope 2.8.7 (unreleased)
Bugs fixed
- Collector #2116: sequence.sort() did not work properly
locale related comparison methods
Zope 2.8.7 (2007/05/29)
Features added:
...
...
lib/python/DocumentTemplate/sequence/SortEx.py
View file @
09f5e800
##############################################################################
#
# Copyright (c) 200
1
Zope Corporation and Contributors. All Rights Reserved.
# Copyright (c) 200
2
Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.
0
(ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.
1
(ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
...
...
@@ -17,7 +17,8 @@ eg Sort(sequence, (("akey", "nocase"), ("anotherkey", "cmp", "desc")))
$Id$
"""
from
types
import
TupleType
from
App.config
import
getConfiguration
def
sort
(
sequence
,
sort
=
(),
_
=
None
,
mapping
=
0
):
"""
...
...
@@ -82,7 +83,7 @@ def sort(sequence, sort=(), _=None, mapping=0):
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,12 +134,25 @@ basic_type={type(''): 1, type(0): 1, type(0.0): 1, type(()): 1, type([]): 1,
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
():
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
def
strcoll_nocase
(
str1
,
str2
)
:
r
eturn
strcoll
(
str1
.
lower
(),
str2
.
lower
()
)
else
:
r
aise
RuntimeError
(
"strcoll() is only available for a proper 'locale' configuration in zope.conf"
)
def
make_sortfunctions
(
sortfields
,
_
):
...
...
@@ -168,9 +182,9 @@ def make_sortfunctions(sortfields, _):
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment