From c402e74c8efbdbe54fe4d7abf9efd69cb7cb0b82 Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Wed, 26 May 2004 16:24:30 +0000 Subject: [PATCH] now uses insert_catalog_line git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@930 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ZSQLCatalog/SQLCatalog.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/product/ZSQLCatalog/SQLCatalog.py b/product/ZSQLCatalog/SQLCatalog.py index 49ed19710c..17ee3e2552 100755 --- a/product/ZSQLCatalog/SQLCatalog.py +++ b/product/ZSQLCatalog/SQLCatalog.py @@ -282,6 +282,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): # Generate UID kw['path'] = path kw['uid'] = int(index) + kw['insert_catalog_line'] = insert_catalog_line # LOG # LOG("Call SQL Method %s with args:" % method_name,0, str(kw)) # Alter row @@ -294,17 +295,23 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): # Make sure no duplicates - ie. if an object with different path has same uid, we need a new uid # This can be very dangerous with relations stored in a category table (CMFCategory) # This is why we recommend completely reindexing subobjects after any change of id - if self.hasUid(uid): + catalog_path = self.getPathForUid(uid) + if catalog_path == "reserved": + # Reserved line in catalog table + insert_catalog_line = 0 + elif catalog_path is None: + # No line in catalog table + insert_catalog_line = 1 + else: LOG('SQLCatalog WARNING',0,'assigning new uid to already catalogued object %s' % path) - uid = 0 + uid = 0 + insert_catalog_line = 0 if not uid: # Generate UID index = self.newUid() object.uid = index else: index = uid - - for method_name in self.sql_catalog_object: # We will check if there is an filter on this # method, if so we may not call this zsqlMethod @@ -342,6 +349,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): # Generate UID kw['path'] = path kw['uid'] = index + kw['insert_catalog_line'] = insert_catalog_line # LOG # LOG("Call SQL Method %s with args:" % method_name,0, str(kw)) # Alter row @@ -436,12 +444,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): LOG("Warning: could not find path from uid",0,str(uid)) return None - def hasUid(self, uid): - """ Checks if uid is catalogued for a real object """ - path = self.getPathForUid(uid) - if path is None: return 0 - return path != 'reserved' - def getMetadataForUid(self, uid): """ Accesses a single record for a given uid """ if uid is None: -- 2.30.9