add hook selector
authorSandrine Ribeau <sandrine.ribeau@logilab.fr>
Wed, 09 Dec 2009 16:07:07 +0100
changeset 4086 9b96126e0b14
parent 4085 002ba2a3bb13
child 4087 2b8bc4cfd6ee
add hook selector
server/hook.py
--- a/server/hook.py	Wed Dec 09 16:06:27 2009 +0100
+++ b/server/hook.py	Wed Dec 09 16:07:07 2009 +0100
@@ -156,6 +156,20 @@
     def __call__(self, cls, req, *args, **kwargs):
         return kwargs.get('rtype') in self.expected
 
+class match_rtype_sets(match_search_state):
+    """accept if parameters specified as initializer arguments are specified
+    in named arguments given to the selector
+    """
+
+    def __init__(self, *expected):
+        self.expected = expected
+
+    @lltrace
+    def __call__(self, cls, req, *args, **kwargs):
+        for rel_set in self.expected:
+            if kwargs.get('rtype') in rel_set:
+                return 1
+        return 0
 
 # base class for hook ##########################################################