[FIX] base, website: Avoid .cache confusion with Environment
The attribute cache is mainly used from the Environment class. The ormcache attribute using the same name leads to confusion. Related task: task-3818968 closes odoo/odoo#155264 Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
@@ -90,7 +90,7 @@ class Http(models.AbstractModel):
|
||||
website_id = request.website_routing
|
||||
logger.debug("_generate_routing_rules for website: %s", website_id)
|
||||
rewrites = self._get_rewrites(website_id)
|
||||
self._rewrite_len.cache.add_value(self, website_id, cache_value=len(rewrites))
|
||||
self._rewrite_len.__cache__.add_value(self, website_id, cache_value=len(rewrites))
|
||||
|
||||
for url, endpoint in super()._generate_routing_rules(modules, converters):
|
||||
if url in rewrites:
|
||||
|
||||
@@ -2279,7 +2279,7 @@ class IrModelData(models.Model):
|
||||
for module, name, model, res_id, create_date, write_date in result:
|
||||
# small optimisation: during install a lot of xmlid are created/updated.
|
||||
# Instead of clearing the cache, set the correct value in the cache to avoid a bunch of query
|
||||
self._xmlid_lookup.cache.add_value(self, f"{module}.{name}", cache_value=(model, res_id))
|
||||
self._xmlid_lookup.__cache__.add_value(self, f"{module}.{name}", cache_value=(model, res_id))
|
||||
if create_date != write_date:
|
||||
# something was updated, notify other workers
|
||||
# it is possible that create_date and write_date
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ class ormcache(object):
|
||||
self.method = method
|
||||
self.determine_key()
|
||||
lookup = decorator(self.lookup, method)
|
||||
lookup.cache = self
|
||||
lookup.__cache__ = self
|
||||
return lookup
|
||||
|
||||
def add_value(self, *args, cache_value=None, **kwargs):
|
||||
@@ -173,7 +173,7 @@ def log_ormcache_stats(sig=None, frame=None):
|
||||
def get_cache_key_counter(bound_method, *args, **kwargs):
|
||||
""" Return the cache, key and stat counter for the given call. """
|
||||
model = bound_method.__self__
|
||||
ormcache = bound_method.cache
|
||||
ormcache = bound_method.__cache__
|
||||
cache, key0, counter = ormcache.lru(model)
|
||||
key = key0 + ormcache.key(model, *args, **kwargs)
|
||||
return cache, key, counter
|
||||
|
||||
Reference in New Issue
Block a user