From 20bab327d478cfe8c7cdf95f74d4e1598b21e7b7 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 1 Oct 2015 17:32:26 +0200 Subject: [PATCH] [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. --- openerp/addons/base/ir/ir_http.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index bab377c42e9..9f08d09f170 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -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)