Commit ff1014bc authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fixed potential problems on mutable default values.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@638 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c3075e21
......@@ -78,9 +78,14 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
security = ClassSecurityInfo()
def __init__(self, method_path=None, params={}, sort_on=[],
uids=[], invert_mode=0, list_url='',
columns=[], checked_uids=[]):
def __init__(self, method_path=None, params=None, sort_on=None,
uids=None, invert_mode=0, list_url='',
columns=None, checked_uids=None):
if params is None: params = {}
if sort_on is None: sort_on = []
if uids is None: uids = []
if columns is None: columns = []
if checked_uids is None: checked_uids = []
self.selection_method_path = method_path
self.selection_params = params
self.selection_uids = uids
......@@ -109,6 +114,9 @@ class Selection(Acquisition.Implicit, Traversable, Persistent):
setattr(self, 'selection_%s' % k, v)
def __call__(self, selection_method = None, context=None, REQUEST=None):
LOG("Selection", 0, str(self.__dict__))
LOG("Selection", 0, str(selection_method))
if self.selection_invert_mode is 0:
if selection_method is None:
# XXX Bad hack, we should not have unicode here XXX
......
......@@ -344,10 +344,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
selection.edit(columns=columns)
security.declareProtected(ERP5Permissions.View, 'getSelectionColumns')
def getSelectionColumns(self, selection_name, columns=[], REQUEST=None):
def getSelectionColumns(self, selection_name, columns=None, REQUEST=None):
"""
Returns the columns in the selection
"""
if columns is None: columns = []
selection = self.getSelectionFor(selection_name, REQUEST=REQUEST)
if selection is not None:
if len(selection.selection_columns) > 0:
......@@ -456,10 +457,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
# ListBox related methods
security.declareProtected(ERP5Permissions.View, 'nextPage')
def nextPage(self, listbox_uid, uids=[], REQUEST=None):
def nextPage(self, listbox_uid, uids=None, REQUEST=None):
"""
Access the next page of a list
"""
if uids is None: uids = []
request = REQUEST
form_id = request.form_id
selection_name = request.list_selection_name
......@@ -474,10 +476,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'previousPage')
def previousPage(self, listbox_uid, uids=[], REQUEST=None):
def previousPage(self, listbox_uid, uids=None, REQUEST=None):
"""
Access the previous page of a list
"""
if uids is None: uids = []
request = REQUEST
form_id = request.form_id
selection_name = request.list_selection_name
......@@ -492,10 +495,11 @@ class SelectionTool( UniqueObject, SimpleItem ):
return self.checkAll(selection_name, uids, REQUEST=REQUEST)
security.declareProtected(ERP5Permissions.View, 'setPage')
def setPage(self, listbox_uid, uids=[], REQUEST=None):
def setPage(self, listbox_uid, uids=None, REQUEST=None):
"""
Access the previous page of a list
"""
if uids is None: uids = []
request = REQUEST
form_id = request.form_id
selection_name = request.list_selection_name
......
......@@ -112,11 +112,13 @@ class CopyContainer:
security.declareProtected( Permissions.DeletePortalContent, 'manage_delObjects' )
def manage_delObjects(self, ids=[], uids=[], REQUEST=None):
def manage_delObjects(self, ids=None, uids=None, REQUEST=None):
"""Delete a subordinate object
The objects specified in 'ids' get deleted.
"""
if ids is None: ids = []
if uids is None: uids = []
if len(ids) > 0:
# Use default method
return ObjectManager.manage_delObjects(self, ids, REQUEST)
......@@ -211,7 +213,7 @@ class CopyContainer:
#LOG("unindexObject",0, str(self.id))
security.declareProtected(Permissions.ModifyPortalContent, 'moveObject')
def moveObject(self, idxs=[]):
def moveObject(self, idxs=None):
"""
Reindex the object in the portal catalog.
If idxs is present, only those indexes are reindexed.
......@@ -223,6 +225,7 @@ class CopyContainer:
Passes is_object_moved to catalog to force
reindexing without creating new uid
"""
if idxs is None: idxs = []
if idxs == []:
# Update the modification date.
if hasattr(aq_base(self), 'notifyModified'):
......
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