Commit e2b35e2d authored by Aurel's avatar Aurel

add a log message if length of path is too long for the catalog


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7558 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2a6c1d4b
...@@ -65,7 +65,7 @@ except ImportError: ...@@ -65,7 +65,7 @@ except ImportError:
pass pass
enableReadOnlyTransactionCache = doNothing enableReadOnlyTransactionCache = doNothing
disableReadOnlyTransactionCache = doNothing disableReadOnlyTransactionCache = doNothing
UID_BUFFER_SIZE = 300 UID_BUFFER_SIZE = 300
valid_method_meta_type_list = ('Z SQL Method', 'Script (Python)') valid_method_meta_type_list = ('Z SQL Method', 'Script (Python)')
...@@ -88,22 +88,22 @@ def manage_addSQLCatalog(self, id, title, ...@@ -88,22 +88,22 @@ def manage_addSQLCatalog(self, id, title,
if REQUEST is not None: if REQUEST is not None:
return self.manage_main(self, REQUEST,update_menu=1) return self.manage_main(self, REQUEST,update_menu=1)
class UidBuffer(TM): class UidBuffer(TM):
"""Uid Buffer class caches a list of reserved uids in a transaction-safe way.""" """Uid Buffer class caches a list of reserved uids in a transaction-safe way."""
def __init__(self): def __init__(self):
"""Initialize some variables. """Initialize some variables.
temporary_buffer is used to hold reserved uids created by non-committed transactions. temporary_buffer is used to hold reserved uids created by non-committed transactions.
finished_buffer is used to hold reserved uids created by committed-transactions. finished_buffer is used to hold reserved uids created by committed-transactions.
This distinction is important, because uids by non-committed transactions might become This distinction is important, because uids by non-committed transactions might become
invalid afterwards, so they may not be used by other transactions.""" invalid afterwards, so they may not be used by other transactions."""
self.temporary_buffer = {} self.temporary_buffer = {}
self.finished_buffer = [] self.finished_buffer = []
def _finish(self): def _finish(self):
"""Move the uids in the temporary buffer to the finished buffer.""" """Move the uids in the temporary buffer to the finished buffer."""
tid = get_ident() tid = get_ident()
...@@ -112,7 +112,7 @@ class UidBuffer(TM): ...@@ -112,7 +112,7 @@ class UidBuffer(TM):
del self.temporary_buffer[tid] del self.temporary_buffer[tid]
except KeyError: except KeyError:
pass pass
def _abort(self): def _abort(self):
"""Erase the uids in the temporary buffer.""" """Erase the uids in the temporary buffer."""
tid = get_ident() tid = get_ident()
...@@ -120,7 +120,7 @@ class UidBuffer(TM): ...@@ -120,7 +120,7 @@ class UidBuffer(TM):
del self.temporary_buffer[tid] del self.temporary_buffer[tid]
except KeyError: except KeyError:
pass pass
def __len__(self): def __len__(self):
tid = get_ident() tid = get_ident()
l = len(self.finished_buffer) l = len(self.finished_buffer)
...@@ -129,7 +129,7 @@ class UidBuffer(TM): ...@@ -129,7 +129,7 @@ class UidBuffer(TM):
except KeyError: except KeyError:
pass pass
return l return l
def remove(self, value): def remove(self, value):
self._register() self._register()
for uid_list in self.temporary_buffer.values(): for uid_list in self.temporary_buffer.values():
...@@ -141,7 +141,7 @@ class UidBuffer(TM): ...@@ -141,7 +141,7 @@ class UidBuffer(TM):
self.finished_buffer.remove(value) self.finished_buffer.remove(value)
except ValueError: except ValueError:
pass pass
def pop(self): def pop(self):
self._register() self._register()
tid = get_ident() tid = get_ident()
...@@ -150,7 +150,7 @@ class UidBuffer(TM): ...@@ -150,7 +150,7 @@ class UidBuffer(TM):
except (KeyError, IndexError): except (KeyError, IndexError):
uid = self.finished_buffer.pop() uid = self.finished_buffer.pop()
return uid return uid
def extend(self, iterable): def extend(self, iterable):
self._register() self._register()
tid = get_ident() tid = get_ident()
...@@ -599,7 +599,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -599,7 +599,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
except ConflictError: except ConflictError:
raise raise
except: except:
LOG('SQLCatalog', WARNING, LOG('SQLCatalog', WARNING,
'could not clear catalog with %s' % method_name, error=sys.exc_info()) 'could not clear catalog with %s' % method_name, error=sys.exc_info())
pass pass
...@@ -630,7 +630,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -630,7 +630,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
except ConflictError: except ConflictError:
raise raise
except: except:
LOG('SQLCatalog', WARNING, LOG('SQLCatalog', WARNING,
'could not clear reserved catalog with %s' % \ 'could not clear reserved catalog with %s' % \
method_id, error=sys.exc_info()) method_id, error=sys.exc_info())
raise raise
...@@ -689,7 +689,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -689,7 +689,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
"""Return search result keys. """Return search result keys.
""" """
return self.sql_search_result_keys return self.sql_search_result_keys
def _getCatalogSchema(self, table=None): def _getCatalogSchema(self, table=None):
catalog_schema_dict = getattr(aq_base(self), '_v_catalog_schema_dict', {}) catalog_schema_dict = getattr(aq_base(self), '_v_catalog_schema_dict', {})
...@@ -908,7 +908,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -908,7 +908,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
'Total time: %s<br>' 'Total time: %s<br>'
'Total CPU time: %s' % (`elapse`, `c_elapse`))) 'Total CPU time: %s' % (`elapse`, `c_elapse`)))
def manage_catalogClear(self, REQUEST=None, RESPONSE=None, def manage_catalogClear(self, REQUEST=None, RESPONSE=None,
URL1=None, sql_catalog_id=None): URL1=None, sql_catalog_id=None):
""" clears the whole enchilada """ """ clears the whole enchilada """
self.clear() self.clear()
...@@ -1061,6 +1061,10 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1061,6 +1061,10 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
klass._reserved_uid_lock.release() klass._reserved_uid_lock.release()
elif catalog_path is not None: elif catalog_path is not None:
# An uid conflict happened... Why? # An uid conflict happened... Why?
# can be due to path length
if len(path) > 255:
LOG('SQLCatalog', WARNING, 'path of object %r is too long for catalog. You should use a shorter path.' %(object,))
object.uid = self.newUid() object.uid = self.newUid()
LOG('SQLCatalog', WARNING, LOG('SQLCatalog', WARNING,
'uid of %r changed from %r to %r !!! This can be fatal. You should reindex the whole site immediately.' % (object, uid, object.uid)) 'uid of %r changed from %r to %r !!! This can be fatal. You should reindex the whole site immediately.' % (object, uid, object.uid))
...@@ -1074,7 +1078,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1074,7 +1078,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
try: try:
if not disable_cache: if not disable_cache:
enableReadOnlyTransactionCache(self) enableReadOnlyTransactionCache(self)
method_kw_dict = {} method_kw_dict = {}
for method_name in method_id_list: for method_name in method_id_list:
kw = {} kw = {}
...@@ -1104,12 +1108,12 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1104,12 +1108,12 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
catalogged_object_list.append(object) catalogged_object_list.append(object)
else: else:
catalogged_object_list = object_list catalogged_object_list = object_list
if len(catalogged_object_list) == 0: if len(catalogged_object_list) == 0:
continue continue
method_kw_dict[method_name] = kw method_kw_dict[method_name] = kw
#LOG('catalogObjectList', 0, 'method_name = %s' % (method_name,)) #LOG('catalogObjectList', 0, 'method_name = %s' % (method_name,))
method = getattr(self, method_name) method = getattr(self, method_name)
if method.meta_type == "Z SQL Method": if method.meta_type == "Z SQL Method":
...@@ -1134,13 +1138,13 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1134,13 +1138,13 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
argument_cache[(object.uid, arg)] = value argument_cache[(object.uid, arg)] = value
append(value) append(value)
kw[arg] = value_list kw[arg] = value_list
for method_name in method_id_list: for method_name in method_id_list:
if method_name not in method_kw_dict: if method_name not in method_kw_dict:
continue continue
kw = method_kw_dict[method_name] kw = method_kw_dict[method_name]
method = getattr(self, method_name) method = getattr(self, method_name)
method = aq_base(method).__of__(site_root.portal_catalog) # Use method in method = aq_base(method).__of__(site_root.portal_catalog) # Use method in
# the context of portal_catalog # the context of portal_catalog
# Alter/Create row # Alter/Create row
try: try:
...@@ -1200,7 +1204,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1200,7 +1204,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
""" """
method_name = self.sql_catalog_translation_list method_name = self.sql_catalog_translation_list
return self.catalogObjectList(object_list, method_id_list = (method_name,)) return self.catalogObjectList(object_list, method_id_list = (method_name,))
def deleteTranslationList(self): def deleteTranslationList(self):
"""Delete translations. """Delete translations.
""" """
...@@ -1212,7 +1216,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1212,7 +1216,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
raise raise
except: except:
LOG('SQLCatalog', WARNING, 'could not delete translations', error=sys.exc_info()) LOG('SQLCatalog', WARNING, 'could not delete translations', error=sys.exc_info())
def uniqueValuesFor(self, name): def uniqueValuesFor(self, name):
""" return unique values for FieldIndex name """ """ return unique values for FieldIndex name """
method = getattr(self, self.sql_unique_values) method = getattr(self, self.sql_unique_values)
...@@ -1352,7 +1356,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -1352,7 +1356,7 @@ class Catalog(Folder, Persistent, Acquisition.Implicit, ExtensionClass.Base):
def getSqlCatalogRelatedKeyList(self, **kw): def getSqlCatalogRelatedKeyList(self, **kw):
""" """
Return the list of related keys. Return the list of related keys.
This method can be overidden in order to implement This method can be overidden in order to implement
dynamic generation of some related keys. dynamic generation of some related keys.
""" """
# Do not generate dynamic related key for acceptable_keys # Do not generate dynamic related key for acceptable_keys
......
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