[FIX] ir_http: declare class attributes _routing_map and _rewrite_len

Actually, the two class attributes are only set when calling the
routing_map method. As a consequence, when the url_for function in the
http_routing module tries to access the _rewrite_len attribute, it
may crashe.

This problem arrise in the TestQwebProcessAtt from the website module
when the test is run alone.

It was hidden on the runbot because some missconfigured HttpCase tests were run
at_install before TestQwebProcessAtt. In that particular case, the
routing_map method is called and sets the attribute.

With this commit, the _routing_map and _rewrite_len class attributes are
set on the class at class declaration time.
This commit is contained in:
Christophe Monniez
2019-10-30 12:35:23 +00:00
parent 855b29b6d0
commit b6ed34e134
+3 -3
View File
@@ -82,6 +82,9 @@ class IrHttp(models.AbstractModel):
# Routing map
#------------------------------------------------------
_routing_map = {}
_rewrite_len = {}
@classmethod
def _get_converters(cls):
return {'model': ModelConverter, 'models': ModelsConverter, 'int': SignedIntConverter}
@@ -250,9 +253,6 @@ class IrHttp(models.AbstractModel):
@classmethod
def routing_map(cls, key=None):
if not hasattr(cls, '_routing_map'):
cls._routing_map = {}
cls._rewrite_len = {}
if key not in cls._routing_map:
_logger.info("Generating routing map for key %s" % str(key))
installed = request.registry._init_modules | set(odoo.conf.server_wide_modules)