Commit 51d54c77 authored by Aurel's avatar Aurel

check selection list length before getting an item

use getter on REQUEST for url


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15980 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e95ccce4
......@@ -508,10 +508,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if selection:
method = self.unrestrictedTraverse(selection.method_path)
selection_list = selection(method = method, context=self, REQUEST=REQUEST)
o = selection_list[0]
url = o.absolute_url()
if len(selection_list):
o = selection_list[0]
url = o.absolute_url()
else:
url = REQUEST.getURL()
else:
url = REQUEST.url
url = REQUEST.getURL()
url = '%s/%s?selection_index=%s&selection_name=%s' % (url, form_id, 0, selection_name)
REQUEST.RESPONSE.redirect(url)
......@@ -526,10 +529,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if selection:
method = self.unrestrictedTraverse(selection.method_path)
selection_list = selection(method = method, context=self, REQUEST=REQUEST)
o = selection_list[-1]
url = o.absolute_url()
if len(selection_list):
o = selection_list[-1]
url = o.absolute_url()
else:
url = REQUEST.getURL()
else:
url = REQUEST.url
url = REQUEST.getURL()
url = '%s/%s?selection_index=%s&selection_name=%s' % (url, form_id, -1, selection_name)
REQUEST.RESPONSE.redirect(url)
......@@ -544,10 +550,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if selection:
method = self.unrestrictedTraverse(selection.method_path)
selection_list = selection(method = method, context=self, REQUEST=REQUEST)
o = selection_list[(int(selection_index) + 1) % len(selection_list)]
url = o.absolute_url()
if len(selectionlist):
o = selection_list[(int(selection_index) + 1) % len(selection_list)]
url = o.absolute_url()
else:
url = REQUEST.getURL()
else:
url = REQUEST.url
url = REQUEST.getURL()
url = '%s/%s?selection_index=%s&selection_name=%s' % (url, form_id, int(selection_index) + 1, selection_name)
REQUEST.RESPONSE.redirect(url)
......@@ -562,10 +571,13 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if selection:
method = self.unrestrictedTraverse(selection.method_path)
selection_list = selection(method = method, context=self, REQUEST=REQUEST)
o = selection_list[(int(selection_index) - 1) % len(selection_list)]
url = o.absolute_url()
if len(selection_list):
o = selection_list[(int(selection_index) - 1) % len(selection_list)]
url = o.absolute_url()
else:
url = REQUEST.getURL()
else:
url = REQUEST.url
url = REQUEST.getURL()
url = '%s/%s?selection_index=%s&selection_name=%s' % (url, form_id, int(selection_index) - 1, selection_name)
REQUEST.RESPONSE.redirect(url)
......
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