diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index c023ec0bcf87f66243c4ad0ee0cdbd73e24f1f1b..bde7e29e513dd8c958ed73e2fb1f1237164e4b15 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -888,7 +888,7 @@ class ListBoxRenderer: def getParamDict(self): """Return a dictionary of parameters. """ - params = self.getSelection().getParams() + params = dict(self.getSelection().getParams()) if self.getListMethodName(): # Update parameters, only if list_method is defined. # (i.e. do not update parameters in listboxes intended to show a previously defined selection. @@ -980,6 +980,8 @@ class ListBoxRenderer: # objects in the current ListBox configuration. if 'select_expression' in params: del params['select_expression'] + + self.getSelection().edit(params=params) return params getParamDict = lazyMethod(getParamDict) diff --git a/product/ERP5Form/Selection.py b/product/ERP5Form/Selection.py index 5647b66d341fa199f48ea3db88c001f57cb8a24a..9709e6b45b5b8d6a04addbba0dddce1cd13b5031 100644 --- a/product/ERP5Form/Selection.py +++ b/product/ERP5Form/Selection.py @@ -97,7 +97,7 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): """ method_path=None - params={} + params=None sort_on=() default_sort_on=() uids=() @@ -158,23 +158,25 @@ class Selection(Acquisition.Implicit, Traversable, Persistent): security.declarePrivate('edit') def edit(self, params=None, **kw): - setattr(self, MEMCACHED_TOOL_MODIFIED_FLAG_PROPERTY_ID, True) + if self.isMemcachedUsed(): + setattr(self, MEMCACHED_TOOL_MODIFIED_FLAG_PROPERTY_ID, True) if params is not None: - self.params = {} - for key in params.keys(): - # We should only keep params which do not start with field_ - # in order to make sure we do not collect unwanted params - # resulting form the REQUEST generated by an ERP5Form submit - if key[0:6] != 'field_': - self.params[key] = params[key] + # We should only keep params which do not start with field_ + # in order to make sure we do not collect unwanted params + # resulting form the REQUEST generated by an ERP5Form submit + params = dict([item for item in params.iteritems() \ + if not item[0].startswith('field_')]) + if self.params != params: + self.params = params if kw is not None: - for k,v in kw.items(): + for k,v in kw.iteritems(): if k in ('domain', 'report', 'domain_path', 'report_path', 'domain_list', 'report_list') or v is not None: # XXX Because method_path is an URI, it must be in ASCII. # Shouldn't Zope automatically does this conversion? -yo - if k == 'method_path' and type(v) is type(u'a'): + if k == 'method_path' and isinstance(v, unicode): v = v.encode('ascii') - setattr(self, k, v) + if getattr(self, k, None) != v: + setattr(self, k, v) def _p_independent(self) : return 1 diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py index d6607b210abf22b31fd4172e7ce9c03cc1bf69e8..fe82b9e1675ab42f9c801fbb8d15199553606a8f 100644 --- a/product/ERP5Form/SelectionTool.py +++ b/product/ERP5Form/SelectionTool.py @@ -200,7 +200,8 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): # Set the name so that this selection itself can get its own name. selection_object.edit(name = selection_name) - self._setSelectionToContainer(selection_name, selection_object) + if self.getSelectionFor(selection_name) != selection_object: + self._setSelectionToContainer(selection_name, selection_object) security.declareProtected(ERP5Permissions.View, 'getSelectionParamsFor') def getSelectionParamsFor(self, selection_name, params=None, REQUEST=None): @@ -227,7 +228,7 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): Sets the selection params for a given selection_name """ selection_object = self.getSelectionFor(selection_name, REQUEST) - if selection_object: + if selection_object is not None: selection_object.edit(params=params) else: selection_object = Selection(params=params)