Commit 320d96ce authored by Alexandre Boeglin's avatar Alexandre Boeglin

recatch ValueError in _checkConsistency ...


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8491 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e65716b6
...@@ -72,7 +72,7 @@ class XMLMatrix(Folder): ...@@ -72,7 +72,7 @@ class XMLMatrix(Folder):
if not self.index.has_key(base_id): if not self.index.has_key(base_id):
return None return None
cell_id_list = [base_id] cell_id_list = [base_id]
append = cell_id_list.append append = cell_id_list.append
index = self.index[base_id] index = self.index[base_id]
...@@ -93,9 +93,9 @@ class XMLMatrix(Folder): ...@@ -93,9 +93,9 @@ class XMLMatrix(Folder):
cell = self.getCell(*kw, **kwd) cell = self.getCell(*kw, **kwd)
if cell is None: if cell is None:
return None return None
return cell.getProperty(base_id) return cell.getProperty(base_id)
security.declareProtected( Permissions.View, 'hasCell' ) security.declareProtected( Permissions.View, 'hasCell' )
def hasCell(self, *kw , **kwd): def hasCell(self, *kw , **kwd):
""" """
...@@ -150,7 +150,7 @@ class XMLMatrix(Folder): ...@@ -150,7 +150,7 @@ class XMLMatrix(Folder):
""" """
if not hasattr(self, 'index'): if not hasattr(self, 'index'):
return 0 return 0
base_id = kwd.get('base_id', "cell") base_id = kwd.get('base_id', "cell")
if not self.index.has_key(base_id): if not self.index.has_key(base_id):
return 0 return 0
...@@ -309,7 +309,7 @@ class XMLMatrix(Folder): ...@@ -309,7 +309,7 @@ class XMLMatrix(Folder):
# We don't need the old index any more, we # We don't need the old index any more, we
# can set the new index # can set the new index
self.index[base_id] = new_index[base_id] self.index[base_id] = new_index[base_id]
security.declareProtected( Permissions.ModifyPortalContent, 'setCellRange' ) security.declareProtected( Permissions.ModifyPortalContent, 'setCellRange' )
def setCellRange(self, *kw, **kwd): def setCellRange(self, *kw, **kwd):
""" """
...@@ -326,13 +326,13 @@ class XMLMatrix(Folder): ...@@ -326,13 +326,13 @@ class XMLMatrix(Folder):
""" """
The asCellRange script is Portal Type dependent The asCellRange script is Portal Type dependent
which is not the case with this kind of code which is not the case with this kind of code
a better implementation consists in defining asCellRange as a a better implementation consists in defining asCellRange as a
generic method at matrix level (OverridableMethod(portal_type)) generic method at matrix level (OverridableMethod(portal_type))
which lookups for script in class, meta_type and PT form which lookups for script in class, meta_type and PT form
interaction could be implemented with interaction workflow interaction could be implemented with interaction workflow
this method should be renamed updateCellRange or updateMatrixCellRange this method should be renamed updateCellRange or updateMatrixCellRange
base_id is parameter of updateCellRange base_id is parameter of updateCellRange
asCellRange scripts should be unified if possible asCellRange scripts should be unified if possible
""" """
script = self._getTypeBasedMethod('asCellRange', script_id=script_id) script = self._getTypeBasedMethod('asCellRange', script_id=script_id)
...@@ -343,7 +343,7 @@ class XMLMatrix(Folder): ...@@ -343,7 +343,7 @@ class XMLMatrix(Folder):
"Did not find cell range script for portal type: %r" %\ "Did not find cell range script for portal type: %r" %\
self.getPortalType() self.getPortalType()
self._setCellRange(base_id=base_id, *cell_range) self._setCellRange(base_id=base_id, *cell_range)
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'updateCellRange') 'updateCellRange')
def updateCellRange(self, base_id='cell', script_id=None, **kw): def updateCellRange(self, base_id='cell', script_id=None, **kw):
...@@ -351,7 +351,7 @@ class XMLMatrix(Folder): ...@@ -351,7 +351,7 @@ class XMLMatrix(Folder):
self._updateCellRange(base_id=base_id, script_id=script_id, **kw) self._updateCellRange(base_id=base_id, script_id=script_id, **kw)
self.reindexObject() self.reindexObject()
security.declareProtected( Permissions.ModifyPortalContent, security.declareProtected( Permissions.ModifyPortalContent,
'_renameCellRange' ) '_renameCellRange' )
def _renameCellRange(self, *kw, **kwd): def _renameCellRange(self, *kw, **kwd):
...@@ -622,12 +622,12 @@ class XMLMatrix(Folder): ...@@ -622,12 +622,12 @@ class XMLMatrix(Folder):
if not hasattr(self, 'index'): if not hasattr(self, 'index'):
return () return ()
return self.index.keys() return self.index.keys()
security.declareProtected( Permissions.ModifyPortalContent, 'delMatrix' ) security.declareProtected( Permissions.ModifyPortalContent, 'delMatrix' )
def delMatrix(self, base_id = 'cell'): def delMatrix(self, base_id = 'cell'):
""" """
Delete all cells for a given base_id Delete all cells for a given base_id
XXX BAD NAME: make a difference between deleting matrix and matrix cells XXX BAD NAME: make a difference between deleting matrix and matrix cells
""" """
ids = self.getCellIds(base_id = base_id) ids = self.getCellIds(base_id = base_id)
...@@ -668,12 +668,11 @@ class XMLMatrix(Folder): ...@@ -668,12 +668,11 @@ class XMLMatrix(Folder):
is_int = 1 is_int = 1
test_num = None test_num = None
while base_id_len > 0: while base_id_len > 0:
# XXX it is bad to use except without exception name ! try:
# try:
# if this succeeds, it is very likely a cell with an id such as quantity_X_Y_0_Z # if this succeeds, it is very likely a cell with an id such as quantity_X_Y_0_Z
test_num = int(object_id_split[base_id_len-1]) test_num = int(object_id_split[base_id_len-1])
# except: except ValueError:
# is_int = 0 is_int = 0
if not is_int: break if not is_int: break
base_id_len -= 1 base_id_len -= 1
if base_id_len > 0: if base_id_len > 0:
...@@ -726,7 +725,7 @@ class XMLMatrix(Folder): ...@@ -726,7 +725,7 @@ class XMLMatrix(Folder):
security.declareProtected( Permissions.ModifyPortalContent, 'notifyAfterUpdateRelatedContent' ) security.declareProtected( Permissions.ModifyPortalContent, 'notifyAfterUpdateRelatedContent' )
def notifyAfterUpdateRelatedContent(self, previous_category_url, new_category_url): def notifyAfterUpdateRelatedContent(self, previous_category_url, new_category_url):
""" """
We must do some matrix range update in the event matrix range We must do some matrix range update in the event matrix range
is defined by a category is defined by a category
""" """
LOG('XMLMatrix notifyAfterUpdateRelatedContent', 0, str(new_category_url)) LOG('XMLMatrix notifyAfterUpdateRelatedContent', 0, str(new_category_url))
...@@ -736,7 +735,7 @@ class XMLMatrix(Folder): ...@@ -736,7 +735,7 @@ class XMLMatrix(Folder):
new_cell_range = [] new_cell_range = []
for range_item_list in cell_range: for range_item_list in cell_range:
new_range_item_list = map(lambda c: update_method(c, previous_category_url, new_category_url), range_item_list) new_range_item_list = map(lambda c: update_method(c, previous_category_url, new_category_url), range_item_list)
new_cell_range.append(new_range_item_list) new_cell_range.append(new_range_item_list)
kwd = {'base_id': base_id} kwd = {'base_id': base_id}
LOG('XMLMatrix notifyAfterUpdateRelatedContent matrix', 0, str(base_id)) LOG('XMLMatrix notifyAfterUpdateRelatedContent matrix', 0, str(base_id))
LOG('XMLMatrix notifyAfterUpdateRelatedContent _renameCellRange', 0, str(new_cell_range)) LOG('XMLMatrix notifyAfterUpdateRelatedContent _renameCellRange', 0, str(new_cell_range))
......
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