From 9b9b5d09ca47964e26fe9e501f4f85c8102e9efd Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Tue, 19 Nov 2013 14:52:00 +0100 Subject: [PATCH] [ADD] methods attribute to @http.route decorator bzr revid: fme@openerp.com-20131119135200-jesz3kijqa0ape40 --- openerp/http.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openerp/http.py b/openerp/http.py index abfbbeaac97..bedda78bef7 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -194,7 +194,7 @@ class WebRequest(object): warnings.warn('please use request.registry and request.cr directly', DeprecationWarning) yield (self.registry, self.cr) -def route(route, type="http", auth="user"): +def route(route, type="http", auth="user", methods=None): """ Decorator marking the decorated method as being a handler for requests. The method must be part of a subclass of ``Controller``. @@ -211,6 +211,7 @@ def route(route, type="http", auth="user"): * ``none``: The method is always active, even if there is no database. Mainly used by the framework and authentication modules. There request code will not have any facilities to access the database nor have any configuration indicating the current database nor the current user. + :param methods: A sequence of http methods this route applies to. If not specified, all methods are allowed. """ assert type in ["http", "json"] def decorator(f): @@ -218,6 +219,7 @@ def route(route, type="http", auth="user"): f.routes = route else: f.routes = [route] + f.methods = methods f.exposed = type if getattr(f, "auth", None) is None: f.auth = auth @@ -523,7 +525,7 @@ def routing_map(modules, nodb_only, converters=None): url = o._cp_path.rstrip('/') + '/' + url.lstrip('/') if url.endswith("/") and len(url) > 1: url = url[: -1] - routing_map.add(werkzeug.routing.Rule(url, endpoint=mv)) + routing_map.add(werkzeug.routing.Rule(url, endpoint=mv, methods=mv.methods)) return routing_map #----------------------------------------------------------