It may happen than the routing map is cleared while rendering a qweb
view. For example, if an asset bundle is regenerated, the previous one
is unlinked, which causes a cache clearing.
Previously-generated EndPoint objects aren't found any more in the new
routing map, so `request.endpoint` cannot be used any more after a cache
clearing.
This commit adds hash and comparison magic methods on http.EndPoint so
that EndPoint objects created by a previous routing map generation can
still be used after a cache clearing.
Two tests were added: one to test the comparison and hash methods, and
the other to test them in a real-case rendering.
Commit 80a04f7ebed fixed this bug too, but introduced another issue
which caused many OPW, so it was quickly reverted by deb23450f18 along
with its performance improvement 33167b3928c. This commit replaces
80a04f7ebed with another way to fix the issue.
A third test has been added in order to avoid reintroducing this other
issue.
By the way, this commit also removes the EndPoint.arguments attribute,
as commit 17f1992698 removed all usages of this attribute in Odoo 9.0,
but left this initialization here.
OPW-2834546
OPW-2834549
OPW-2834625
X-original-commit: bdc45422f5c715782b147eecda2403386ba7eb4a
Part-of: odoo/odoo#91034
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
from odoo.tests import HttpCase
|
|
|
|
|
|
class TestHttpEndPoint(HttpCase):
|
|
|
|
def test_can_clear_routing_map_during_render(self):
|
|
"""
|
|
The routing map might be cleared while rendering a qweb view.
|
|
For example, if an asset bundle is regenerated the old one is unlinked,
|
|
which causes a cache clearing.
|
|
This test ensures that the rendering still works, even in this case.
|
|
"""
|
|
homepage_id = self.env['ir.ui.view'].search([
|
|
('website_id', '=', self.env.ref('website.default_website').id),
|
|
('key', '=', 'website.homepage'),
|
|
])
|
|
self.env['ir.ui.view'].create({
|
|
'name': 'Add cache clear to Home',
|
|
'type': 'qweb',
|
|
'mode': 'extension',
|
|
'inherit_id': homepage_id.id,
|
|
'arch_db': """
|
|
<t t-call="website.layout" position="before">
|
|
<t t-esc="website.env['ir.http']._clear_routing_map()"/>
|
|
</t>
|
|
""",
|
|
})
|
|
|
|
r = self.url_open('/')
|
|
r.raise_for_status()
|