diff options
| author | chm@openerp.com <> | 2014-03-10 17:36:30 +0100 |
|---|---|---|
| committer | chm@openerp.com <> | 2014-03-10 17:36:30 +0100 |
| commit | e5fbd2ba1a7bef6711270ee8d19cc7f5bdbfd777 (patch) | |
| tree | 0de761d7a3f677c6bbf2be27c9f827ffec5549c7 /addons/website | |
| parent | 9ee5a6d0a17d1393a8cc2dd7f1e1852326f831aa (diff) | |
| parent | 5e036bbf7c1e79dc1fe91b9be04c329aad7db995 (diff) | |
[MERGE] from trunk
bzr revid: chm@openerp.com-20140310163630-xoqbu4y5wr9ptj7h
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/models/ir_http.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 46b9efc15a8..f73138313ab 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -78,21 +78,18 @@ class ir_http(orm.AbstractModel): return self._dispatch() - def _postprocess_args(self, arguments): - url = request.httprequest.url - for arg in arguments.itervalues(): - if isinstance(arg, orm.browse_record) and isinstance(arg._uid, RequestUID): - placeholder = arg._uid - arg._uid = request.uid - try: - good_slug = slug(arg) - if str(arg.id) != placeholder.value and placeholder.value != good_slug: - # TODO: properly recompose the url instead of using replace() - url = url.replace(placeholder.value, good_slug) - except KeyError: - return self._handle_exception(werkzeug.exceptions.NotFound()) - if url != request.httprequest.url: - werkzeug.exceptions.abort(werkzeug.utils.redirect(url)) + def _postprocess_args(self, arguments, rule): + for arg, val in arguments.items(): + # Replace uid placeholder by the current request.uid + if isinstance(val, orm.browse_record) and isinstance(val._uid, RequestUID): + val._uid = request.uid + try: + _, path = rule.build(arguments) + assert path is not None + except Exception: + return self._handle_exception(werkzeug.exceptions.NotFound()) + if path != request.httprequest.path: + return werkzeug.utils.redirect(path) def _handle_exception(self, exception=None, code=500): if isinstance(exception, werkzeug.exceptions.HTTPException) and hasattr(exception, 'response') and exception.response: |
