[Erp5-report] r37397 aurel - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Aug 2 13:36:28 CEST 2010
Author: aurel
Date: Mon Aug 2 13:36:19 2010
New Revision: 37397
URL: http://svn.erp5.org?rev=37397&view=rev
Log:
add a new property on catalog so that developer can decide if he wants
to have error raised on UID check or not
Modified:
erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
Modified: erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SQLCatalog.py?rev=37397&r1=37396&r2=37397&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Mon Aug 2 13:36:19 2010
@@ -512,6 +512,12 @@ class Catalog(Folder,
'type': 'multiple selection',
'select_variable' : 'getPythonMethodIds',
'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,
sql_catalog_role_keys = ()
sql_catalog_local_role_keys = ()
sql_catalog_table_vote_scripts = ()
+ sql_catalog_raise_error_on_uid_check = True
# These are ZODB variables, so shared by multiple Zope instances.
# This is set to the last logical time when clearReserved is called.
@@ -1318,9 +1325,13 @@ class Catalog(Folder,
raise RuntimeError, 'could not set missing uid for %r' % (object,)
elif check_uid:
if uid in assigned_uid_dict:
- raise ValueError('uid of %r is %r and '
- 'is already assigned to %s in catalog !!! This can be fatal.' %
- (object, uid, assigned_uid_dict[uid]))
+ error_message = 'uid of %r is %r and ' \
+ 'is already assigned to %s in catalog !!! This can be fatal.' % \
+ (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()
index = path_uid_dict.get(path)
@@ -1370,10 +1381,15 @@ class Catalog(Folder,
LOG('SQLCatalog', ERROR,
'uid of %r changed from %r to %r as old one is assigned'
' to %s in catalog !!! This can be fatal.' % (
- 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.' %
- (object, uid, catalog_path))
+ object, uid, object.uid, catalog_path))
+
+ error_message = 'uid of %r is %r and ' \
+ '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
assigned_uid_dict[uid] = object
More information about the Erp5-report
mailing list