chainall / chainfirst ensures selectors are instantiated tls-sprint
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 18 Feb 2009 10:05:15 +0100
branchtls-sprint
changeset 759 e044f28372bd
parent 758 0c0dfd33a76d
child 760 95b3419e94c5
chainall / chainfirst ensures selectors are instantiated
selectors.py
vregistry.py
--- a/selectors.py	Wed Feb 18 10:03:58 2009 +0100
+++ b/selectors.py	Wed Feb 18 10:05:15 2009 +0100
@@ -347,7 +347,7 @@
 @lltrace
 def authenticated_user(cls, req, *args, **kwargs):
     """accept if user is authenticated"""
-    return not anonymous_user(cls, req, *args, **kwargs)
+    return not anonymous_user()(cls, req, *args, **kwargs)
 
 @objectify_selector
 @lltrace
--- a/vregistry.py	Wed Feb 18 10:03:58 2009 +0100
+++ b/vregistry.py	Wed Feb 18 10:05:15 2009 +0100
@@ -693,7 +693,9 @@
     will be the sum of each selector'score
     """
     assert selectors
-    selector = AndSelector(*selectors)
+    # XXX do we need to create the AndSelector here, a tuple might be enough
+    selector = AndSelector(*[_instantiate_selector(selector)
+                             for selector in selectors])
     if 'name' in kwargs:
         selector.__name__ = kwargs['name']
     return selector
@@ -704,7 +706,8 @@
     will be the first non-zero selector score
     """
     assert selectors
-    selector = OrSelector(*selectors)
+    selector = OrSelector(*[_instantiate_selector(selector)
+                            for selector in selectors])
     if 'name' in kwargs:
         selector.__name__ = kwargs['name']
     return selector