predicates.py
branchstable
changeset 9013 b4bcabf55e77
parent 8889 be91151107f6
child 9157 3e4bef7d514d
--- a/predicates.py	Fri Jun 14 16:13:24 2013 +0200
+++ b/predicates.py	Fri Jun 14 16:26:25 2013 +0200
@@ -1489,6 +1489,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'.