Commit a2c7ef15 authored by Vincent Pelletier's avatar Vincent Pelletier

ZSQLCatalog.SQLCatalog: Drop incorrect code.

Backward compatibility was not implemented everywhere, and it is masking
bugs: not all parameters were provided to these ZSQLMethods, which can
cause all sorts of bugs and performance issues because of DTML defaulting
to acquisition context for missing arguments. Drop this overcomplex code.
parent b156b14b
...@@ -1801,46 +1801,32 @@ class Catalog(Folder, ...@@ -1801,46 +1801,32 @@ class Catalog(Folder,
security.declarePrivate('getUidDictForPathList') security.declarePrivate('getUidDictForPathList')
def getUidDictForPathList(self, path_list): def getUidDictForPathList(self, path_list):
""" Looks up into catalog table to convert path into uid """ """ Looks up into catalog table to convert path into uid """
# Get the appropriate SQL Method return {
method = getattr(self, self.sql_getitem_by_path) x.path: x.uid
path_uid_dict = {} for x in getattr(
try: self,
search_result = method(path_list = path_list) self.sql_getitem_by_path,
# If not empty, return first record )(
for result in search_result: path=None,
path_uid_dict[result.path] = result.uid path_list=path_list,
except ValueError, message: uid_only=False,
# This code is only there for backward compatibility )
# XXX this must be removed one day }
# This means we have the previous zsql method
# and we must call the method for every path
for path in path_list:
search_result = method(path = path)
if len(search_result) > 0:
path_uid_dict[path] = search_result[0].uid
return path_uid_dict
security.declarePrivate('getPathDictForUidList') security.declarePrivate('getPathDictForUidList')
def getPathDictForUidList(self, uid_list): def getPathDictForUidList(self, uid_list):
""" Looks up into catalog table to convert uid into path """ """ Looks up into catalog table to convert uid into path """
# Get the appropriate SQL Method return {
method = getattr(self, self.sql_getitem_by_uid) x.uid: x.path
uid_path_dict = {} for x in getattr(
try: self,
search_result = method(uid_list = uid_list) self.sql_getitem_by_uid,
# If not empty, return first record )(
for result in search_result: uid=None,
uid_path_dict[result.uid] = result.path uid_list=uid_list,
except ValueError, message: path_only=False,
# This code is only there for backward compatibility )
# XXX this must be removed one day }
# This means we have the previous zsql method
# and we must call the method for every path
for uid in uid_list:
search_result = method(uid = uid)
if len(search_result) > 0:
uid_path_dict[uid] = search_result[0].path
return uid_path_dict
security.declarePrivate('hasPath') security.declarePrivate('hasPath')
def hasPath(self, path): def hasPath(self, path):
......
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