Commit 185a39e1 authored by 's avatar

- added tpValues method (http://collector.zope.org/Zope/1339)

parent 821e31bb
......@@ -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)
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment