add the match_http_method predicate (closes #2559932)
This aim at creating views which are selected on other HTTP methods
(PUT, DELETE, ...)
--- a/predicates.py Thu Mar 21 18:35:19 2013 +0100
+++ b/predicates.py Thu Jan 17 14:55:07 2013 +0100
@@ -1470,6 +1470,15 @@
return frozenset(req.form)
+class match_http_method(ExpectedValuePredicate):
+ """Return non-zero score if one of the HTTP methods specified as
+ initializer arguments is the HTTP method of the request (GET, POST, ...).
+ """
+
+ def __call__(self, cls, req, **kwargs):
+ return int(req.http_method() in self.expected)
+
+
class match_edited_type(ExpectedValuePredicate):
"""return non-zero if main edited entity type is the one specified as
initializer argument, or is among initializer arguments if `mode` == 'any'.