[FIX] possible incorrect request.env

On a new database, logged as administrator, installing
``website_slides`` commonly (but not systematically) leads to a 403
error when the module install redirects to the slides
index (``/slides``).

The issue here is the installation of the slides module deletes the
existing routing map, which needs to be regenerated. The regeneration is
performed at the start of URL dispatching *before authentication* but
accesses ``request.env` in order to look up the list of installed
modules, which generates and caches (due to env being a lazy_property)
an ``Environment(cr, None, context)``.

Once regeneration and auth are done the controller is executed with
``request.env`` still being set to ``Environment(cr, None, context)``
and thus the first tentative access (search) to an object blowing up
with an AccessError. The next request or an initial request not
accessing ``request.env`` will work fine as they'll reuse the routing
map generated by the initial request.

Fixed by just getting the set of installed modules from the registry.
This commit is contained in:
Xavier Morel
2015-10-02 11:25:42 +02:00
parent 3a26046b88
commit 20bab327d4
+1 -8
View File
@@ -190,14 +190,7 @@ class ir_http(osv.AbstractModel):
def routing_map(self):
if not hasattr(self, '_routing_map'):
_logger.info("Generating routing map")
Modules = request.env['ir.module.module'].sudo()
installed = {
module.name
for module in Modules.search([
('state', 'in', ('installed', 'to remove', 'to upgrade')),
('name', '!=', 'web')
])
}
installed = request.registry._init_modules - {'web'}
if openerp.tools.config['test_enable']:
installed.add(openerp.modules.module.current_test)
mods = [''] + openerp.conf.server_wide_modules + sorted(installed)