predicates.py
changeset 8751 1a97d46701e7
parent 8535 268b6349baf3
child 8867 6ad000b91347
--- 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'.