Commit 5a3c16e4 authored by Jérome Perrin's avatar Jérome Perrin

ERP5Type: Don't log when cache factory is not found

This should prevent all the warnings like

    WARNING Cache.__call__ Factory erp5_content_medium not found, method <function getTypeList at 0x7fd8b2ce4cd0> executed without cache
    WARNING Cache.__call__ Factory erp5_content_long not found, method <function _getPortalGroupedTypeSet at 0x7fd8bc613750> executed without cache

we have during startup.

This code tried to detect the case where cache system was not
fully initialized an only log in this case, but there does not seem to
be a reliable way to detect that cache is supposed to be ready and that
log was not really useful - If some methods are executed without cache
for some reason (which as far as I know never happens), then we should
be able to notice the problem because it's slow.
parent f5d883c0
Pipeline #9053 failed with stage
in 0 seconds
......@@ -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