[Erp5-report] r26189 - /erp5/trunk/products/ZSQLCatalog/SQLCatalog.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Mar 28 00:49:15 CET 2009
Author: kazuhiko
Date: Sat Mar 28 00:49:15 2009
New Revision: 26189
URL: http://svn.erp5.org?rev=26189&view=rev
Log:
* use 1L instead of 0L as the minumum number of uid because it is easier to avoid boolean condition mistakes.
* assign a unique uid for documents like tool objects that have uid=0 (not 0L) from the beginning.
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=26189&r1=26188&r2=26189&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] (original)
+++ erp5/trunk/products/ZSQLCatalog/SQLCatalog.py [utf8] Sat Mar 28 00:49:15 2009
@@ -1034,7 +1034,7 @@
id_tool = getattr(self.getPortalObject(), 'portal_ids', None)
if id_tool is not None:
if self._max_uid is None:
- self._max_uid = Length()
+ self._max_uid = Length(1)
uid_list = id_tool.generateNewLengthIdList(id_group='catalog_uid',
id_count=UID_BUFFER_SIZE, default=self._max_uid())
# TODO: if this method is kept and former uid allocation code is
@@ -1125,7 +1125,7 @@
# raise RuntimeError, 'Newly generated UID (%s) seems too big ! - vincent' % (uid,)
# end
if self._max_uid is None:
- self._max_uid = Length()
+ self._max_uid = Length(1)
if uid > self._max_uid():
self._max_uid.set(uid)
return long(uid)
@@ -1316,6 +1316,10 @@
raise
except:
raise RuntimeError, 'could not set missing uid for %r' % (object,)
+ elif isinstance(object.uid, int) and object.uid == 0:
+ # Several Tool objects have uid=0 (not 0L) from the beginning, but
+ # we need an unique uid for each object.
+ object.uid = self.newUid()
elif check_uid:
uid = object.uid
if uid in assigned_uid_dict:
More information about the Erp5-report
mailing list