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
185a39e1
Commit
185a39e1
authored
Jan 26, 2005
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added tpValues method (
http://collector.zope.org/Zope/1339
)
parent
821e31bb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
lib/python/OFS/OrderSupport.py
lib/python/OFS/OrderSupport.py
+28
-5
lib/python/OFS/tests/testOrderSupport.py
lib/python/OFS/tests/testOrderSupport.py
+13
-0
No files found.
lib/python/OFS/OrderSupport.py
View file @
185a39e1
...
...
@@ -20,6 +20,7 @@ from types import StringType
from
AccessControl
import
ClassSecurityInfo
from
AccessControl.Permissions
import
access_contents_information
from
AccessControl.Permissions
import
manage_properties
from
Acquisition
import
aq_base
from
DocumentTemplate.sequence
import
sort
from
Globals
import
InitializeClass
...
...
@@ -67,7 +68,7 @@ class OrderSupport:
else
:
message
=
'Error: No items were specified!'
return
self
.
manage_main
(
self
,
REQUEST
,
skey
=
'position'
,
manage_tabs_message
=
message
)
manage_tabs_message
=
message
,
update_menu
=
1
)
security
.
declareProtected
(
manage_properties
,
'manage_move_objects_down'
)
def
manage_move_objects_down
(
self
,
REQUEST
,
ids
=
None
,
delta
=
1
):
...
...
@@ -83,7 +84,7 @@ class OrderSupport:
else
:
message
=
'Error: No items were specified!'
return
self
.
manage_main
(
self
,
REQUEST
,
skey
=
'position'
,
manage_tabs_message
=
message
)
manage_tabs_message
=
message
,
update_menu
=
1
)
security
.
declareProtected
(
manage_properties
,
'manage_move_objects_to_top'
)
def
manage_move_objects_to_top
(
self
,
REQUEST
,
ids
=
None
):
...
...
@@ -99,7 +100,7 @@ class OrderSupport:
else
:
message
=
'Error: No items were specified!'
return
self
.
manage_main
(
self
,
REQUEST
,
skey
=
'position'
,
manage_tabs_message
=
message
)
manage_tabs_message
=
message
,
update_menu
=
1
)
security
.
declareProtected
(
manage_properties
,
'manage_move_objects_to_bottom'
)
def
manage_move_objects_to_bottom
(
self
,
REQUEST
,
ids
=
None
):
...
...
@@ -115,14 +116,14 @@ class OrderSupport:
else
:
message
=
'Error: No items were specified!'
return
self
.
manage_main
(
self
,
REQUEST
,
skey
=
'position'
,
manage_tabs_message
=
message
)
manage_tabs_message
=
message
,
update_menu
=
1
)
security
.
declareProtected
(
manage_properties
,
'manage_set_default_sorting'
)
def
manage_set_default_sorting
(
self
,
REQUEST
,
key
,
reverse
):
""" Set default sorting key and direction.
"""
self
.
setDefaultSorting
(
key
,
reverse
)
return
self
.
manage_main
(
self
,
REQUEST
)
return
self
.
manage_main
(
self
,
REQUEST
,
update_menu
=
1
)
#
...
...
@@ -256,4 +257,26 @@ class OrderSupport:
self
.
moveObjectToPosition
(
new_id
,
old_position
)
return
result
def
tpValues
(
self
):
# Return a list of subobjects, used by tree tag.
r
=
[]
if
hasattr
(
aq_base
(
self
),
'tree_ids'
):
tree_ids
=
self
.
tree_ids
try
:
tree_ids
=
list
(
tree_ids
)
except
TypeError
:
pass
if
hasattr
(
tree_ids
,
'sort'
):
tree_ids
.
sort
()
for
id
in
tree_ids
:
if
hasattr
(
self
,
id
):
r
.
append
(
self
.
_getOb
(
id
))
else
:
# this part is different from the ObjectManager code
r
=
[
obj
for
obj
in
self
.
objectValues
()
if
getattr
(
obj
,
'isPrincipiaFolderish'
,
False
)
]
r
=
sort
(
r
,
(
(
self
.
_default_sort_key
,
'cmp'
,
'asc'
),
)
)
if
self
.
_default_sort_reverse
:
r
.
reverse
()
return
r
InitializeClass
(
OrderSupport
)
lib/python/OFS/tests/testOrderSupport.py
View file @
185a39e1
...
...
@@ -146,6 +146,19 @@ class TestOrderSupport(TestCase):
)
)
def
test_tpValues
(
self
):
f
=
self
.
_makeOne
()
f
.
o2
.
isPrincipiaFolderish
=
True
f
.
o3
.
isPrincipiaFolderish
=
True
f
.
o4
.
isPrincipiaFolderish
=
True
self
.
failUnlessEqual
(
f
.
tpValues
(),
[
f
.
o2
,
f
.
o3
,
f
.
o4
]
)
f
.
setDefaultSorting
(
'meta_type'
,
False
)
self
.
failUnlessEqual
(
f
.
tpValues
(),
[
f
.
o3
,
f
.
o2
,
f
.
o4
]
)
f
.
setDefaultSorting
(
'position'
,
True
)
self
.
failUnlessEqual
(
f
.
tpValues
(),
[
f
.
o4
,
f
.
o3
,
f
.
o2
]
)
def
test_interface
(
self
):
from
OFS.IOrderSupport
import
IOrderedContainer
...
...
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