From 579bc9c94d54b3c69241bce4918fb960d7dc9463 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Thu, 9 Sep 2010 21:02:01 +0000 Subject: [PATCH] support an empty selection_name, that means we do not store the selection. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38248 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/ListBox.py | 9 ++++++--- product/ERP5Form/Tool/SelectionTool.py | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 4d779b02da..80eab3faeb 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -267,7 +267,7 @@ class ListBoxWidget(Widget.Widget): description=('The name of the selection to ' 'store selection parameters'), default='', - required=1) + required=0) property_names.append('selection_name') meta_types = fields.ListTextAreaField('meta_types', @@ -2425,13 +2425,16 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): error = sys.exc_info()) else: try: - url = '%s/view?selection_index=%s&selection_name=%s&ignore_layout:int=%s&reset:int=1' % ( + url = '%s/view?ignore_layout:int=%s&reset:int=1' % ( # brain.absolute_url() is slow because it invokes # _aq_dynamic() every time to get brain.REQUEST, # so we call request.physicalPathToURL() directly # instead of brain.absolute_url(). request.physicalPathToURL(brain.getPath()), - self.index, selection_name, ignore_layout) + ignore_layout) + if selection_name: + url += '&selection_index=%s&selection_name=%s' % ( + self.index, selection_name) except AttributeError: pass diff --git a/product/ERP5Form/Tool/SelectionTool.py b/product/ERP5Form/Tool/SelectionTool.py index f350765779..7a87939ced 100644 --- a/product/ERP5Form/Tool/SelectionTool.py +++ b/product/ERP5Form/Tool/SelectionTool.py @@ -251,6 +251,8 @@ class SelectionTool( BaseTool, SimpleItem ): """ if isinstance(selection_name, (tuple, list)): selection_name = selection_name[0] + if not selection_name: + return None selection = self._getSelectionFromContainer(selection_name) if selection is not None: return selection.__of__(self) @@ -263,6 +265,8 @@ class SelectionTool( BaseTool, SimpleItem ): """ Sets the selection instance for a given selection_name """ + if not selection_name: + return if selection_object != None: # Set the name so that this selection itself can get its own name. selection_object.edit(name=selection_name) -- 2.30.9