[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.
This commit is contained in:
Xavier Morel 2014-06-13 16:11:56 +02:00
parent 0f01df42ea
commit 1587663fd2
1 changed files with 2 additions and 3 deletions

View File

@ -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: