Commit 6397d636 authored by Yoshinori Okuji's avatar Yoshinori Okuji

backup to tuples for selection sort order

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2738 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a6c6d3be
......@@ -183,14 +183,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
if len(sort_on) == 0:
sort_on = getattr(self, 'default_sort_on', [])
if len(sort_on) > 0:
new_sort_index = []
for (k , v) in sort_on:
if v == 'descending' or v == 'reverse':
new_sort_index += ['%s DESC' % k]
else:
new_sort_index += ['%s' % k]
sort_order_string = string.join(new_sort_index,',')
self.params['sort_on'] = sort_order_string
self.params['sort_on'] = sort_on
elif self.params.has_key('sort_on'):
del self.params['sort_on']
if method is not None:
......@@ -257,6 +250,13 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
self.params = {}
return self.params
security.declarePublic('getSortOrder')
def getSortOrder(self):
"""
Return sort order stored in selection
"""
return self.sort_on
security.declarePublic('getListUrl')
def getListUrl(self):
result = ''
......
......@@ -1255,30 +1255,40 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
else:
so = [so]
new_index = []
if sort_index is not None:
# We must now turn sort_index into
# a dict with keys as sort keys and values as sort order
if type(sort_index) is type('a'):
if sort_index.find(',')>0:
index_list = [x.strip() for x in sort_index.split(',')]
else:
index_list = [sort_index]
for index in index_list:
if index.find(' ') > 0:
new_index.append([x.strip() for x in index.split(' ')])
elif so is not None and len(so)==len(index_list):
new_index.append([index,so[index_list.index(index)]])
else:
new_index.append([index,'ascending'])
sort_index = new_index
sort_index = [(sort_index, so)]
elif type(sort_index) is not type(()) and type(sort_index) is not type([]):
sort_index = None
#new_index = []
#if sort_index is not None:
# if type(sort_index) is type('a'):
# if sort_index.find(',')>0:
# index_list = [x.strip() for x in sort_index.split(',')]
# else:
# index_list = [sort_index]
# for index in index_list:
# if index.find(' ') > 0:
# new_index.append([x.strip() for x in index.split(' ')])
# elif so is not None and len(so)==len(index_list):
# new_index.append([index,so[index_list.index(index)]])
# else:
# new_index.append([index,'ascending'])
#sort_index = new_index
# If sort_index is a dictionnary
# then parse it and change it
sort_on = None
#LOG('sorting', 0, str(sort_index))
if sort_index is not None:
try:
new_sort_index = []
for (k , v) in sort_index:
if len(acceptable_key_map[k]) == 1 :
if '.' in k:
pass
elif len(acceptable_key_map[k]) == 1 :
k = acceptable_key_map[k][0] + '.' + k
elif query_table:
k = query_table + '.' + k
......
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