summaryrefslogtreecommitdiff
path: root/odoo/http.py
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2019-06-07 06:22:41 +0000
committerChristophe Simonis <chs@odoo.com>2019-06-08 13:53:57 +0000
commit521f7d36c1ff929ea52e9ed6fd4170bd3b968b19 (patch)
tree87aa091eec0fa7960a5e6c11aafa30c1b77eb8af /odoo/http.py
parentf167ae7d6e4298474293ede5cbef97d98a0883cc (diff)
[IMP] odoo: ignore unsupported args from controller
Before this commit, call a controller defined as: ``` @http.route('/route', type='http', auth='public') def controller_func(self, foo): do_it() ``` and called with url like /route?foo=1&bar=2 will crash with an exception: `TypeError: controller_func() got an unexpected keyword argument 'bar'` Now, we remove the extra parameters if the controller doesn't support it. This case is not uncommon, you can easily arrive in this case with utm or debug as extra parameter. closes odoo/odoo#33962 Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'odoo/http.py')
-rw-r--r--odoo/http.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/odoo/http.py b/odoo/http.py
index 3f4dd6fad27..d4b1aef8a1a 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -507,8 +507,16 @@ def route(route=None, **kw):
else:
routes = [route]
routing['routes'] = routes
+
@functools.wraps(f)
def response_wrap(*args, **kw):
+ # if controller cannot be called with extra args (utm, debug, ...), call endpoint ignoring them
+ spec = inspect.getargspec(f)
+ if not spec.keywords:
+ ignored = ['<%s=%s>' % (k, kw.pop(k)) for k in list(kw) if k not in spec.args]
+ if ignored:
+ _logger.info("<function %s.%s> called ignoring args %s" % (f.__module__, f.__name__, ', '.join(ignored)))
+
response = f(*args, **kw)
if isinstance(response, Response) or f.routing_type == 'json':
return response