diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index b109bdbecd8..7726c4c8cf7 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -37,10 +37,9 @@ class ir_http(orm.AbstractModel): def _auth_method_public(self): if not request.session.uid: - domain_name = request.httprequest.environ.get('HTTP_HOST', '').split(':')[0] - website_id = self.pool['website']._get_current_website_id(request.cr, openerp.SUPERUSER_ID, domain_name, context=request.context) - if website_id: - request.uid = self.pool['website'].browse(request.cr, openerp.SUPERUSER_ID, website_id, request.context).user_id.id + website = self.pool['website'].get_current_website(request.cr, openerp.SUPERUSER_ID, context=request.context) + if website: + request.uid = website.user_id.id else: request.uid = self.pool['ir.model.data'].xmlid_to_res_id(request.cr, openerp.SUPERUSER_ID, 'base', 'public_user') else: diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 2784b55fef4..2c1a373d586 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -350,17 +350,17 @@ class website(osv.osv): lang['hreflang'] = lang['short'] return langs - @openerp.tools.ormcache(skiparg=4) - def _get_current_website_id(self, cr, uid, domain_name, context=None): - ids = self.search(cr, uid, [('name', '=', domain_name)], limit=1, context=context) + @openerp.tools.ormcache(skiparg=3) + def _get_current_website_id(self, cr, uid, domain_name): + ids = self.search(cr, uid, [('name', '=', domain_name)], limit=1) if ids: return ids[0] else: - return self.search(cr, uid, [], limit=1, context=context)[0] + return self.search(cr, uid, [], limit=1)[0] def get_current_website(self, cr, uid, context=None): domain_name = request.httprequest.environ.get('HTTP_HOST', '').split(':')[0] - website_id = self._get_current_website_id(cr, uid, domain_name, context=context) + website_id = self._get_current_website_id(cr, uid, domain_name) request.context['website_id'] = website_id return self.browse(cr, uid, website_id, context=context)