From edc0743ce3e82f463b14e217cf452e34427e0df9 Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Wed, 25 Apr 2007 01:03:51 +0000 Subject: [PATCH] Make sure that newUid returns a long value when it is not None. Make sure that uid is long in indexing. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14213 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ZSQLCatalog/SQLCatalog.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index b488e52931..08328fd9f9 100644 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -1284,7 +1284,7 @@ class Catalog( Folder, self._max_uid = Length() if uid > self._max_uid(): self._max_uid.set(uid) - return uid + return long(uid) else: raise CatalogError("Could not retrieve new uid") finally: @@ -1456,13 +1456,15 @@ class Catalog( Folder, path = object.getPath() index = self.getUidForPath(path) try: - index = int(index) + index = long(index) except TypeError: - pass + index = None if index is not None and index < 0: raise CatalogError, 'A negative uid %d is used for %s. Your catalog is broken. Recreate your catalog.' % (index, path) if index: - if uid != index: + # Use "is not" instead of "!=", because we want to make sure that + # uid becomes long, if it is int. + if uid is not index: LOG('SQLCatalog', WARNING, 'uid of %r changed from %r (property) to %r (catalog, by path) !!! This can be fatal. You should reindex the whole site immediately.' % (object, uid, index)) uid = index object.uid = uid -- 2.30.9