Commit b6386024 authored by Aurel's avatar Aurel

add a new property on catalog so that developer can decide if he wants

to have error raised on UID check or not


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37397 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2866d9ad
...@@ -512,6 +512,12 @@ class Catalog(Folder, ...@@ -512,6 +512,12 @@ class Catalog(Folder,
'type': 'multiple selection', 'type': 'multiple selection',
'select_variable' : 'getPythonMethodIds', 'select_variable' : 'getPythonMethodIds',
'mode': 'w' }, 'mode': 'w' },
{ 'id': 'sql_catalog_raise_error_on_uid_check',
'title': 'Raise error on UID check',
'description': 'Boolean used to tell if we raise error when uid check fail',
'type': 'boolean',
'default' : True,
'mode': 'w' },
) )
...@@ -551,6 +557,7 @@ class Catalog(Folder, ...@@ -551,6 +557,7 @@ class Catalog(Folder,
sql_catalog_role_keys = () sql_catalog_role_keys = ()
sql_catalog_local_role_keys = () sql_catalog_local_role_keys = ()
sql_catalog_table_vote_scripts = () sql_catalog_table_vote_scripts = ()
sql_catalog_raise_error_on_uid_check = True
# These are ZODB variables, so shared by multiple Zope instances. # These are ZODB variables, so shared by multiple Zope instances.
# This is set to the last logical time when clearReserved is called. # This is set to the last logical time when clearReserved is called.
...@@ -1318,9 +1325,13 @@ class Catalog(Folder, ...@@ -1318,9 +1325,13 @@ class Catalog(Folder,
raise RuntimeError, 'could not set missing uid for %r' % (object,) raise RuntimeError, 'could not set missing uid for %r' % (object,)
elif check_uid: elif check_uid:
if uid in assigned_uid_dict: if uid in assigned_uid_dict:
raise ValueError('uid of %r is %r and ' error_message = 'uid of %r is %r and ' \
'is already assigned to %s in catalog !!! This can be fatal.' % 'is already assigned to %s in catalog !!! This can be fatal.' % \
(object, uid, assigned_uid_dict[uid])) (object, uid, assigned_uid_dict[uid])
if not self.sql_catalog_raise_error_on_uid_check:
LOG("SQLCatalog.catalogObjectList", ERROR, error_message)
else:
raise ValueError(error_message)
path = object.getPath() path = object.getPath()
index = path_uid_dict.get(path) index = path_uid_dict.get(path)
...@@ -1371,9 +1382,14 @@ class Catalog(Folder, ...@@ -1371,9 +1382,14 @@ class Catalog(Folder,
'uid of %r changed from %r to %r as old one is assigned' 'uid of %r changed from %r to %r as old one is assigned'
' to %s in catalog !!! This can be fatal.' % ( ' to %s in catalog !!! This can be fatal.' % (
object, uid, object.uid, catalog_path)) object, uid, object.uid, catalog_path))
raise ValueError('uid of %r is %r and '
'is already assigned to %s in catalog !!! This can be fatal.' % error_message = 'uid of %r is %r and ' \
(object, uid, catalog_path)) 'is already assigned to %s in catalog !!! This can be fatal.' \
% (object, uid, catalog_path)
if not self.sql_catalog_raise_error_on_uid_check:
LOG('SQLCatalog', ERROR, error_message)
else:
raise ValueError(error_message)
uid = object.uid uid = object.uid
assigned_uid_dict[uid] = object assigned_uid_dict[uid] = object
......
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