From 48752864e7aac7e33aeb8082d3be78a67a593559 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Mon, 3 May 2004 15:11:53 +0000
Subject: [PATCH] Check if each axis is empty.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@807 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/XMLMatrix.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/product/ERP5Type/XMLMatrix.py b/product/ERP5Type/XMLMatrix.py
index 8d7c2c42be..0a6cb99e34 100755
--- a/product/ERP5Type/XMLMatrix.py
+++ b/product/ERP5Type/XMLMatrix.py
@@ -626,6 +626,18 @@ class XMLMatrix(Folder):
               if object.id not in to_delete:
                 to_delete += [object.id]
             else:
+              # Check empty indices.
+              empty_list = []
+              for i in self.index[base_id].keys():
+                if self.index[base_id][i] is None or len(self.index[base_id][i]) == 0:
+                  error_message = "There is no id for the %dth axis of base_id %s" % (i, base_id)
+                  if fixit: error_message += ' (fixed)'
+                  errors += [(self.getRelativeUrl(), 'XMLMatrix inconsistency',102,error_message)]
+                  empty_list.append(i)
+              if fixit:
+                for i in empty_list:
+                  del self.index[base_id][i]
+
               len_id = len(self.index[base_id])
               if len(object_id_split) != (len_id + base_id_len): # +1 for the quantity
                 error_message = "Dimension of cell is %s but should be %s" % (len(object_id_split)
-- 
2.30.9