Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zope-container
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
Boxiang Sun
zope-container
Commits
53c4361d
Commit
53c4361d
authored
Jun 13, 2008
by
Christophe Combelles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used a collator for the localized sorting of the Adding menu
parent
d882d96d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
CHANGES.txt
CHANGES.txt
+1
-0
src/zope/app/container/browser/adding.py
src/zope/app/container/browser/adding.py
+8
-3
src/zope/app/container/browser/tests/test_adding.py
src/zope/app/container/browser/tests/test_adding.py
+3
-3
No files found.
CHANGES.txt
View file @
53c4361d
...
...
@@ -7,6 +7,7 @@ CHANGES
- fixed #238579 / #163149: error with unicode traversing
- fixed #221025 : adding menu is sorted with translated item
by using a collator (better localized sorting)
- fixed #227617 :
- prevent the namechooser from failing on '+', '@' and '/'
- added tests in the namechooser
...
...
src/zope/app/container/browser/adding.py
View file @
53c4361d
...
...
@@ -22,7 +22,7 @@ $Id$
__docformat__
=
'restructuredtext'
import
zope.security.checker
from
zope.component
import
getMultiAdapter
from
zope.component
import
getMultiAdapter
,
queryAdapter
from
zope.component
import
getUtility
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryUtility
...
...
@@ -43,7 +43,8 @@ from zope.app.container.interfaces import IAdding, INameChooser
from
zope.app.container.interfaces
import
IContainerNamesContainer
from
zope.app.pagetemplate.viewpagetemplatefile
import
ViewPageTemplateFile
from
zope.app.publisher.browser.menu
import
getMenu
from
zope.i18n
import
translate
from
zope.i18n.interfaces.locales
import
ICollator
from
zope.i18n.locales.fallbackcollator
import
FallbackCollator
class
Adding
(
BrowserView
):
implements
(
IAdding
,
IPublishTraverse
)
...
...
@@ -187,7 +188,11 @@ class Adding(BrowserView):
context
=
self
.
request
)
result
.
append
(
item
)
result
.
sort
(
lambda
a
,
b
:
cmp
(
a
[
'title'
],
b
[
'title'
]))
# sort the adding info with a collator instead of a basic unicode sort
collator
=
queryAdapter
(
self
.
request
.
locale
,
ICollator
)
if
collator
is
None
:
collator
=
FallbackCollator
(
self
.
request
.
locale
)
result
.
sort
(
key
=
lambda
x
:
collator
.
key
(
x
[
'title'
]))
return
result
def
isSingleMenuItem
(
self
):
...
...
src/zope/app/container/browser/tests/test_adding.py
View file @
53c4361d
...
...
@@ -225,7 +225,7 @@ def test_constraint_driven_addingInfo():
... 'TestMenu')
>>> defineMenuItem(TestMenu, IAdding, '', 'item1')
>>> defineMenuItem(TestMenu, IAdding, '', '
i
tem2')
>>> defineMenuItem(TestMenu, IAdding, '', '
I
tem2')
>>> defineMenuItem(AddMenu, IAdding, '', 'item3', extra={'factory': 'f1'})
>>> defineMenuItem(AddMenu, IAdding, '', 'item4', extra={'factory': 'f2'})
...
...
@@ -272,8 +272,8 @@ def test_constraint_driven_addingInfo():
3
>>> items[0]['title']
u'item1'
>>> items[1]['title']
u'
i
tem2'
>>> items[1]['title']
# the collator ordered this one correctly!
u'
I
tem2'
>>> items[2]['title']
u'item3'
"""
...
...
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