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):
groups[path] = deepcopy(obj.groups)
# copy the object
if (getattr(aq_base(obj), '_mt_index', None) is not None and
obj._count() == 0):
# some btrees were exported in a corrupted state. They're empty but
# their metadata-index (._mt_index) contains entries which in
obj._count() != len(obj._mt_index.keys())):
# Some btrees were exported in a corrupted state.
# Their meta_type-index (._mt_index) contains entries which in
# 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,
'Cleaning corrupted BTreeFolder2 object at %r.' % (path,))
obj._initBTrees()
......
......@@ -3243,7 +3243,7 @@ class Base(
try:
return min(history[0]['time']
for history in history_list.itervalues()
if history)
if history and 'time' in history[0])
except ValueError:
pass
if getattr(aq_base(self), 'CreationDate', None) is not None:
......
......@@ -43,29 +43,25 @@ from warnings import warn
DEFAULT_CACHE_SCOPE = 'GLOBAL'
DEFAULT_CACHE_FACTORY = 'erp5_ui_short'
is_cache_initialized = 0
is_cache_ready = 0
is_cache_initialized = False
def initializePortalCachingProperties(self):
""" Init CachingMethod properties."""
## check if global CachingMethod is initialized in RAM for this ERP5 site. If not init it
global is_cache_initialized
global is_cache_ready
if not is_cache_initialized:
portal_caches = getattr(self.getPortalObject(), 'portal_caches', None)
if portal_caches is None:
return
# 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
try:
portal_caches.updateCache()
except AttributeError:
is_cache_initialized = 0
is_cache_initialized = False
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):
......@@ -272,12 +268,8 @@ class CachingMethod:
# on CachingMethod instead of self, we want a global variable
cache_factory = CachingMethod.factories[self.cache_factory]
except KeyError:
global is_cache_ready
if is_cache_ready:
## 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))
# No cache factory ready, execute without cache. This happens during
# initialisation
value = self.callable_object(*args, **kwd)
else:
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