Commit a8f32683 authored by Jérome Perrin's avatar Jérome Perrin

Prevent some useless logs

This removes some logs happening a lot during tests, when installing business templates or indexing documents.

See merge request !1105
parents c366e0eb 5a3c16e4
Pipeline #9510 failed with stage
in 0 seconds
...@@ -1408,11 +1408,11 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1408,11 +1408,11 @@ class ObjectTemplateItem(BaseTemplateItem):
groups[path] = deepcopy(obj.groups) groups[path] = deepcopy(obj.groups)
# copy the object # copy the object
if (getattr(aq_base(obj), '_mt_index', None) is not None and if (getattr(aq_base(obj), '_mt_index', None) is not None and
obj._count() == 0): obj._count() != len(obj._mt_index.keys())):
# some btrees were exported in a corrupted state. They're empty but # Some btrees were exported in a corrupted state.
# their metadata-index (._mt_index) contains entries which in # Their meta_type-index (._mt_index) contains entries which in
# Zope 2.12 are used for .objectIds(), .objectValues() and # Zope 2.12 are used for .objectIds(), .objectValues() and
# .objectItems(). In these cases, force the # .objectItems(). In these cases, recreate index.
LOG('Products.ERP5.Document.BusinessTemplate', WARNING, LOG('Products.ERP5.Document.BusinessTemplate', WARNING,
'Cleaning corrupted BTreeFolder2 object at %r.' % (path,)) 'Cleaning corrupted BTreeFolder2 object at %r.' % (path,))
obj._initBTrees() obj._initBTrees()
......
...@@ -3243,7 +3243,7 @@ class Base( ...@@ -3243,7 +3243,7 @@ class Base(
try: try:
return min(history[0]['time'] return min(history[0]['time']
for history in history_list.itervalues() for history in history_list.itervalues()
if history) if history and 'time' in history[0])
except ValueError: except ValueError:
pass pass
if getattr(aq_base(self), 'CreationDate', None) is not None: if getattr(aq_base(self), 'CreationDate', None) is not None:
......
...@@ -43,29 +43,25 @@ from warnings import warn ...@@ -43,29 +43,25 @@ from warnings import warn
DEFAULT_CACHE_SCOPE = 'GLOBAL' DEFAULT_CACHE_SCOPE = 'GLOBAL'
DEFAULT_CACHE_FACTORY = 'erp5_ui_short' DEFAULT_CACHE_FACTORY = 'erp5_ui_short'
is_cache_initialized = 0 is_cache_initialized = False
is_cache_ready = 0
def initializePortalCachingProperties(self): def initializePortalCachingProperties(self):
""" Init CachingMethod properties.""" """ Init CachingMethod properties."""
## check if global CachingMethod is initialized in RAM for this ERP5 site. If not init it ## check if global CachingMethod is initialized in RAM for this ERP5 site. If not init it
global is_cache_initialized global is_cache_initialized
global is_cache_ready
if not is_cache_initialized: if not is_cache_initialized:
portal_caches = getattr(self.getPortalObject(), 'portal_caches', None) portal_caches = getattr(self.getPortalObject(), 'portal_caches', None)
if portal_caches is None: if portal_caches is None:
return return
# we set is_cache_initialized right now to prevent infinite loops # we set is_cache_initialized right now to prevent infinite loops
is_cache_initialized = 1 is_cache_initialized = True
## update cache structure from portal_caches ## update cache structure from portal_caches
try: try:
portal_caches.updateCache() portal_caches.updateCache()
except AttributeError: except AttributeError:
is_cache_initialized = 0 is_cache_initialized = False
return return
# we mark the cache as ready after initialization, because initialization
# itself will cause cache misses that we want to ignore
is_cache_ready = 1
class ZODBCookie(Persistent): class ZODBCookie(Persistent):
...@@ -272,12 +268,8 @@ class CachingMethod: ...@@ -272,12 +268,8 @@ class CachingMethod:
# on CachingMethod instead of self, we want a global variable # on CachingMethod instead of self, we want a global variable
cache_factory = CachingMethod.factories[self.cache_factory] cache_factory = CachingMethod.factories[self.cache_factory]
except KeyError: except KeyError:
global is_cache_ready # No cache factory ready, execute without cache. This happens during
if is_cache_ready: # initialisation
## no caching enabled for this site or no such cache factory
LOG("Cache.__call__", WARNING,
"Factory %s not found, method %s executed without cache" % (
self.cache_factory, self.callable_object))
value = self.callable_object(*args, **kwd) value = self.callable_object(*args, **kwd)
else: else:
value = cache_factory( value = cache_factory(
......
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