Commit ad12a47e authored by Julien Muchembled's avatar Julien Muchembled

Be stricter when 2 FS Document/Tool have same name

parent 8addd60c
......@@ -963,28 +963,14 @@ def registerDocumentClass(module_name, class_name):
old_value = document_class_registry.get(class_name)
new_value = "%s.%s" % (module_name, class_name)
if old_value is not None:
old_was_erp5 = old_value.startswith('Products.ERP5')
new_is_erp5 = module_name.startswith('Products.ERP5')
conflict = True
if not old_was_erp5:
if new_is_erp5:
# overwrite the non-erp5 class with the erp5 class
# likely to happen with e.g. CMF Category Tool and ERP5 Category Tool
LOG('Utils', INFO, 'Replacing non-ERP5 class %s by ERP5 class %s' %
(old_value, new_value))
conflict = False
elif not new_is_erp5:
# argh, trying to overwrite an existing erp5 class.
LOG('Utils', INFO,
'Ignoring replacement of ERP5 class %s by non-ERP5 class %s' %
(old_value, new_value))
if old_value:
if class_name == 'CategoryTool':
assert module_name == 'Products.CMFCategory.CategoryTool'
LOG('Utils', WARNING,
'Ignoring replacement of %s by %s' % (old_value, new_value))
return
if conflict:
raise TypeError("Class %s and %s from different products have the "
"same name" % (old_value, new_value))
raise Exception("Class %s and %s from different products have the "
"same name" % (old_value, new_value))
document_class_registry[class_name] = new_value
......
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