Commit 0ee2d852 authored by Alexandre Boeglin's avatar Alexandre Boeglin

- object is a python type, use obj as a variable instead

- obj.id can be a function, for some zope objects, use obj.getId() instead


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13426 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent acff071e
...@@ -226,29 +226,30 @@ class XMLMatrix(Folder): ...@@ -226,29 +226,30 @@ class XMLMatrix(Folder):
# create a movement in dimension i between old_place and new_place # create a movement in dimension i between old_place and new_place
movement[base_id][i][old_place] = new_place movement[base_id][i][old_place] = new_place
# Rename every 'object_name' by 'temp_object_name' # Rename every 'object_id' by 'temp_object_id'
object_id_list = [] object_id_list = []
for object in self.objectValues(): for obj in self.objectValues():
if object.id.find(base_id) == 0: object_id = obj.getId()
if object_id.find(base_id) == 0:
# We want to make sure we have only base_id, ex: foo_0_0 and # We want to make sure we have only base_id, ex: foo_0_0 and
# not foo_bar_0_0 # not foo_bar_0_0
if (object.id) > len(base_id): if (object_id) > len(base_id):
try: try:
int(object.id[len(base_id)+1:].split('_')[0]) int(object_id[len(base_id)+1:].split('_')[0])
test = self._getOb(object.id) # If the object was created test = self._getOb(object_id) # If the object was created
# during this transaction, # during this transaction,
# then we do not need to # then we do not need to
# work on it # work on it
object_id_list += [object.id] object_id_list += [object_id]
except ValueError, KeyError: except ValueError, KeyError:
pass pass
for object_id in object_id_list: for object_id in object_id_list:
new_name = 'temp_' + object_id new_name = 'temp_' + object_id
object = self._getOb(object_id) obj = self._getOb(object_id)
object.isIndexable = 0 # block reindexing at this time obj.isIndexable = 0 # block reindexing at this time
object.id = new_name obj.id = new_name
self._setObject(new_name, aq_base(object)) self._setObject(new_name, aq_base(obj))
self._delObject(object_id) self._delObject(object_id)
for object_id in object_id_list: for object_id in object_id_list:
...@@ -661,13 +662,14 @@ class XMLMatrix(Folder): ...@@ -661,13 +662,14 @@ class XMLMatrix(Folder):
if not hasattr(self, 'index'): if not hasattr(self, 'index'):
self.index = PersistentMapping() self.index = PersistentMapping()
# We will check each cell of the matrix the matrix # We will check each cell of the matrix the matrix
for object in self.objectValues(): for obj in self.objectValues():
# obect.id is equal to something like 'something_quantity_3_2' object_id = obj.getId()
# obect_id is equal to something like 'something_quantity_3_2'
# So we need to check for every object.id if the value # So we need to check for every object.id if the value
# looks like good or not. We split the name # looks like good or not. We split the name
# check each key in index # check each key in index
# First we make sure this is a cell # First we make sure this is a cell
object_id_split = object.id.split('_') object_id_split = object_id.split('_')
# We try to find the first split id which is an int # We try to find the first split id which is an int
base_id_len = len(object_id_split) base_id_len = len(object_id_split)
is_int = 1 is_int = 1
...@@ -690,8 +692,8 @@ class XMLMatrix(Folder): ...@@ -690,8 +692,8 @@ class XMLMatrix(Folder):
error_message = "There is no index for base_id %s" % base_id error_message = "There is no index for base_id %s" % base_id
if fixit: error_message += ' (fixed)' if fixit: error_message += ' (fixed)'
errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)] errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)]
if object.id not in to_delete: if object_id not in to_delete:
to_delete += [object.id] to_delete += [object_id]
else: else:
# Check empty indices. # Check empty indices.
empty_list = [] empty_list = []
...@@ -711,16 +713,16 @@ class XMLMatrix(Folder): ...@@ -711,16 +713,16 @@ class XMLMatrix(Folder):
- base_id_len, len_id) - base_id_len, len_id)
if fixit: error_message += ' (fixed)' if fixit: error_message += ' (fixed)'
errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)] errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)]
if object.id not in to_delete: if object_id not in to_delete:
to_delete += [object.id] to_delete += [object_id]
else : else :
for i in range(len_id): for i in range(len_id):
if int(object_id_split[i+base_id_len]) >= len(self.index[base_id][i]): if int(object_id_split[i+base_id_len]) >= len(self.index[base_id][i]):
error_message = "Cell %s is out of bound" % object.id error_message = "Cell %s is out of bound" % object_id
if fixit: error_message += ' (fixed)' if fixit: error_message += ' (fixed)'
errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)] errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)]
if object.id not in to_delete: if object_id not in to_delete:
to_delete += [object.id] to_delete += [object_id]
if fixit and len(to_delete) > 0: if fixit and len(to_delete) > 0:
self.manage_delObjects(to_delete) self.manage_delObjects(to_delete)
......
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