[predicates] objectify the anonymous_user predicate
authorDavid Douard <david.douard@logilab.fr>
Fri, 03 Jul 2015 14:06:57 +0200
changeset 10497 12bc4e92aa62
parent 10496 e95b559a06a2
child 10498 36e48f7ac61a
[predicates] objectify the anonymous_user predicate for the sake of consistency.
predicates.py
--- a/predicates.py	Thu Jul 02 19:54:25 2015 +0200
+++ b/predicates.py	Fri Jul 03 14:06:57 2015 +0200
@@ -1299,6 +1299,7 @@
         return 1
     return 0
 
+
 @objectify_predicate
 def authenticated_user(cls, req, **kwargs):
     """Return 1 if the user is authenticated (i.e. not the anonymous user).
@@ -1310,13 +1311,16 @@
     return 1
 
 
-# XXX == ~ authenticated_user()
-def anonymous_user():
+@objectify_predicate
+def anonymous_user(cls, req, **kwargs):
     """Return 1 if the user is not authenticated (i.e. is the anonymous user).
 
     May only be used on the web side, not on the data repository side.
     """
-    return ~ authenticated_user()
+    if req.session.anonymous_session:
+        return 1
+    return 0
+
 
 class match_user_groups(ExpectedValuePredicate):
     """Return a non-zero score if request's user is in at least one of the