From 1587663fd2f8d70e87f7b34afda4f1b665c1e13b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 13 Jun 2014 16:11:56 +0200 Subject: [PATCH] [FIX] postprocessing of request arguments in website If website is installed but not used/enabled for the current controller, overridden methods like _get_converters will *still run* for the controller's dispatch. This means a ModelConverter used in a controller with website installed but not enabled will use website.models.ir_http.ModelConverter, not base.ir.ir_http.ModelConverter, and base's args postprocessing will *not* be able to convert the placeholder object to a real UID, only website's postprocessing can do so. And as far as I can see there's no reason to skip the URL building validation either, only the multilang stuff relies on and requires that the controller be website enabled (and in fact that it be multilang enabled), so only *that* should be gated behind a flag. Also always call super(), there's no reason not to and others might add args to postprocess on base rather than website, ending up after website in the MRO. --- addons/website/models/ir_http.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 44b3f771f62..8e6846dd7a8 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -93,8 +93,7 @@ class ir_http(orm.AbstractModel): return self._dispatch() def _postprocess_args(self, arguments, rule): - if not getattr(request, 'website_enabled', False): - return super(ir_http, self)._postprocess_args(arguments, rule) + super(ir_http, self)._postprocess_args(arguments, rule) for arg, val in arguments.items(): # Replace uid placeholder by the current request.uid @@ -106,7 +105,7 @@ class ir_http(orm.AbstractModel): except Exception: return self._handle_exception(werkzeug.exceptions.NotFound()) - if request.httprequest.method in ('GET', 'HEAD'): + if getattr(request, 'website_multilang', False) and request.httprequest.method in ('GET', 'HEAD'): generated_path = werkzeug.url_unquote_plus(path) current_path = werkzeug.url_unquote_plus(request.httprequest.path) if generated_path != current_path: