1. Vladimir Mihailenco
  2. flask-principal-main

Commits

"danjac"  committed adbe7db

negate > opposite

  • Participants
  • Parent commits 700c1df
  • Branches default

Comments (0)

Files changed (2)

File flaskext/principal.py

View file
  • Ignore whitespace
     :param needs: The needs for this permission
     """
     def __init__(self, *needs):
-        self.needs = set(needs)
-        self.excludes = set()
         """A set of needs, any of which must be present in an identity to have
         access.
         """
 
+        self.needs = set(needs)
+        self.excludes = set()
+
     def __nonzero__(self):
+        """Equivalent to ``self.can()``.
+        """
         return bool(self.can())
 
     def __and__(self, other):
+        """Does the same thing as ``self.union(other)``
+        """
         return self.union(other)
 
     def __contains__(self, other):
+        """Does the same thing as ``other.issubset(self)``.
+        """
         return other.issubset(self)
 
     def require(self, http_exception=None):
         with self.require(http_exception):
             pass
         
-    def negate(self):
+    def opposite(self):
         """
-        Returns negative of current state (needs->excludes, excludes->needs) 
+        Returns opposite of current state (needs->excludes, excludes->needs) 
         """
 
         p = Permission()

File tests/test_principal.py

View file
  • Ignore whitespace
     assert p2.issubset(p3)
 
 
-def test_negate_permission():
+def test_opposite_permission():
 
     p = Permission(('a', 'b'))
-    d = p.negate()
+    d = p.opposite()
     print d.excludes
     assert ('a', 'b') in d.excludes